negi2725 commited on
Commit
dbbebbe
·
1 Parent(s): 8c0e2f2

via hugging

Browse files
Files changed (2) hide show
  1. main.py +27 -0
  2. requirements.txt +0 -0
main.py CHANGED
@@ -4,10 +4,37 @@ from fastapi.middleware.cors import CORSMiddleware
4
  from app.api.routes import router
5
  from app.core.config import settings
6
  import logging
 
 
7
 
8
  logging.basicConfig(level=logging.INFO)
9
  logger = logging.getLogger(__name__)
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  app = FastAPI(
12
  title="Legal RAG Analysis API",
13
  description="FastAPI backend for legal case analysis using RAG system with LegalBERT predictions and Gemini AI evaluation",
 
4
  from app.api.routes import router
5
  from app.core.config import settings
6
  import logging
7
+ import os
8
+ from huggingface_hub import snapshot_download
9
 
10
  logging.basicConfig(level=logging.INFO)
11
  logger = logging.getLogger(__name__)
12
 
13
+ # Hugging Face model & dataset download
14
+ logger.info("Downloading model and dataset from Hugging Face Hub...")
15
+
16
+ HF_TOKEN = os.getenv("HF_TOKEN") # Set in environment variables
17
+
18
+ # Download FAISS index dataset
19
+ FAISS_INDEX_PATH = snapshot_download(
20
+ repo_id="negi2725/dataRag",
21
+ repo_type="dataset",
22
+ token=HF_TOKEN
23
+ )
24
+
25
+ # Download LegalBERT model
26
+ MODEL_PATH = snapshot_download(
27
+ repo_id="negi2725/legalBert",
28
+ token=HF_TOKEN
29
+ )
30
+
31
+ logger.info(f"FAISS index files downloaded to: {FAISS_INDEX_PATH}")
32
+ logger.info(f"Model files downloaded to: {MODEL_PATH}")
33
+
34
+ # Make these paths accessible globally in your app if needed
35
+ os.environ["FAISS_INDEX_PATH"] = FAISS_INDEX_PATH
36
+ os.environ["MODEL_PATH"] = MODEL_PATH
37
+
38
  app = FastAPI(
39
  title="Legal RAG Analysis API",
40
  description="FastAPI backend for legal case analysis using RAG system with LegalBERT predictions and Gemini AI evaluation",
requirements.txt ADDED
Binary file (6.53 kB). View file