Rom89823974978 commited on
Commit
22e3c3b
·
1 Parent(s): 84ec3e0
backend/rag.py CHANGED
@@ -39,6 +39,30 @@ from functools import lru_cache
39
  logging.basicConfig(level=logging.INFO)
40
  logger = logging.getLogger(__name__)
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  # === Global Embeddings & Cache ===
43
  EMBEDDING = HuggingFaceEmbeddings(model_name=settings.embedding_model)
44
 
 
39
  logging.basicConfig(level=logging.INFO)
40
  logger = logging.getLogger(__name__)
41
 
42
+ class Settings(BaseSettings):
43
+ # Parquet + Whoosh/FAISS
44
+ parquet_path: str = "gs://mda_eu_project/data/consolidated_clean_pred.parquet"
45
+ whoosh_dir: str = "gs://mda_eu_project/whoosh_index"
46
+ vectorstore_path: str = "gs://mda_eu_project/vectorstore_index"
47
+ # Models
48
+ embedding_model: str = "sentence-transformers/LaBSE"
49
+ llm_model: str = "RedHatAI/Meta-Llama-3.1-8B-Instruct-quantized.w4a16"
50
+ cross_encoder_model: str = "cross-encoder/mmarco-mMiniLMv2-L12-H384-v1"
51
+ # RAG parameters
52
+ chunk_size: int = 750
53
+ chunk_overlap: int = 100
54
+ hybrid_k: int = 50
55
+ assistant_role: str = (
56
+ "You are a concise, factual assistant. Cite Document [ID] for each claim."
57
+ )
58
+ skip_warmup: bool = False
59
+ allowed_origins: List[str] = ["*"]
60
+
61
+ class Config:
62
+ env_file = ".env"
63
+
64
+ settings = Settings()
65
+
66
  # === Global Embeddings & Cache ===
67
  EMBEDDING = HuggingFaceEmbeddings(model_name=settings.embedding_model)
68
 
frontend/src/hooks/useAppState.ts CHANGED
@@ -86,10 +86,10 @@ export const useAppState = () => {
86
  setQuestion("");
87
 
88
  try {
89
- const res = await fetch("/api/chat/query", {
90
  method: "POST",
91
  headers: { "Content-Type": "application/json" },
92
- body: JSON.stringify({ question })
93
  });
94
 
95
  const data: { answer: string } = await res.json();
 
86
  setQuestion("");
87
 
88
  try {
89
+ const res = await fetch("/rag", {
90
  method: "POST",
91
  headers: { "Content-Type": "application/json" },
92
+ body: JSON.stringify({ query: question })
93
  });
94
 
95
  const data: { answer: string } = await res.json();