updating the app
Browse files
app.py
CHANGED
@@ -58,31 +58,31 @@ retriever = vectorstore.as_retriever(search_kwargs={"k": 20}) # k=20
|
|
58 |
# System prompt template for long, detailed answers
|
59 |
def build_system(context: str) -> dict:
|
60 |
"""
|
61 |
-
Build
|
62 |
- Act as an expert medical assistant and attentive listener.
|
63 |
-
- Leverage
|
64 |
-
- Ask clarifying follow-up questions if the user
|
65 |
-
- Structure answers clearly
|
66 |
- Cite relevant context sections when appropriate.
|
67 |
-
- Maintain conversational memory
|
68 |
"""
|
69 |
-
prompt =
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
=== Retrieved Context End ==="
|
83 |
-
)
|
84 |
return {"role": "system", "content": prompt}
|
85 |
|
|
|
|
|
86 |
st.title("🩺 DocChatter RAG (Streaming & Memory)")
|
87 |
|
88 |
# Initialize chat history
|
|
|
58 |
# System prompt template for long, detailed answers
|
59 |
def build_system(context: str) -> dict:
|
60 |
"""
|
61 |
+
Build a comprehensive system prompt:
|
62 |
- Act as an expert medical assistant and attentive listener.
|
63 |
+
- Leverage retrieved context to craft detailed, accurate, and empathetic responses.
|
64 |
+
- Ask clarifying follow-up questions if the user's query is ambiguous.
|
65 |
+
- Structure answers clearly with headings, bullet points, and step-by-step explanations.
|
66 |
- Cite relevant context sections when appropriate.
|
67 |
+
- Maintain conversational memory for follow-up continuity.
|
68 |
"""
|
69 |
+
prompt = f"""
|
70 |
+
You are a world-class medical assistant and conversational partner.
|
71 |
+
|
72 |
+
Listen carefully to the user’s questions, reference the context below, and provide a thorough, evidence-based response.
|
73 |
+
If any part of the question is unclear, ask a clarifying question before proceeding.
|
74 |
+
Organize your answer with clear headings or bullet points, and refer back to specific context snippets as needed.
|
75 |
+
Always be empathetic, concise, and precise in your medical explanations.
|
76 |
+
Retain memory of previous user messages to support follow-up interactions.
|
77 |
+
|
78 |
+
=== Retrieved Context Start ===
|
79 |
+
{context}
|
80 |
+
=== Retrieved Context End ===
|
81 |
+
"""
|
|
|
|
|
82 |
return {"role": "system", "content": prompt}
|
83 |
|
84 |
+
{"role": "system", "content": prompt}
|
85 |
+
|
86 |
st.title("🩺 DocChatter RAG (Streaming & Memory)")
|
87 |
|
88 |
# Initialize chat history
|