Aaravkumar commited on
Commit
112ca0f
·
verified ·
1 Parent(s): 747d8bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -17,9 +17,13 @@ from bm25 import BM25
17
  from vector_store import Vectorstore
18
  from retriever import Retriever
19
 
 
 
20
  embedder = Embedder()
21
  sessions: dict = {}
22
 
 
 
23
  MODELS = [
24
  ("Qwen/Qwen2.5-72B-Instruct"),
25
  ("meta-llama/Llama-3.2-3B-Instruct"),
@@ -30,6 +34,7 @@ MODELS = [
30
 
31
  system_prompt = (
32
  "You are a helpful study assistant. Answer the user's question based ONLY on the provided context.\n\n"
 
33
  "FORMATTING RULES (STRICT):\n"
34
  "You MUST format your entire response using valid Markdown.\n"
35
  "1. Use `##` for main section headings.\n"
@@ -106,6 +111,7 @@ async def upload_file(file: UploadFile = File(...)):
106
  @app.post("/chat")
107
  async def chat(chat_req: ChatRequest):
108
  hf_token = os.environ.get("HF_TOKEN")
 
109
  if not hf_token:
110
  raise HTTPException(status_code=500, detail="HF_TOKEN not configured")
111
 
 
17
  from vector_store import Vectorstore
18
  from retriever import Retriever
19
 
20
+ print("done")
21
+
22
  embedder = Embedder()
23
  sessions: dict = {}
24
 
25
+ print("embedder initialized")
26
+
27
  MODELS = [
28
  ("Qwen/Qwen2.5-72B-Instruct"),
29
  ("meta-llama/Llama-3.2-3B-Instruct"),
 
34
 
35
  system_prompt = (
36
  "You are a helpful study assistant. Answer the user's question based ONLY on the provided context.\n\n"
37
+ "if the answer is not contained within the context, respond with: 'I couldn't find relevant information in the document.'\n\n(STRICT)"
38
  "FORMATTING RULES (STRICT):\n"
39
  "You MUST format your entire response using valid Markdown.\n"
40
  "1. Use `##` for main section headings.\n"
 
111
  @app.post("/chat")
112
  async def chat(chat_req: ChatRequest):
113
  hf_token = os.environ.get("HF_TOKEN")
114
+
115
  if not hf_token:
116
  raise HTTPException(status_code=500, detail="HF_TOKEN not configured")
117