Skip to content

Commit ebaf4a4

Browse files
added deploy code2
1 parent e785d29 commit ebaf4a4

2 files changed

Lines changed: 29 additions & 20 deletions

File tree

new_architecture_v3_deploy.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,20 @@ def medical_chatbot_pipeline(query, chat_history, retrieved_chunks, context_foll
263263
answer_prompt = f"""
264264
You are a professional medical assistant.
265265
266-
Constraints:
267-
- Answer ONLY from <context>.
268-
- Use concise bullet points (sub-bullets allowed), ~150 words max.
269-
- Start with: "According to the retrieved source"
270-
- Be liberal: if the context and query share the core topic, answer from context even if not the exact angle.
271-
- Do not add external facts.
272-
273-
If <followup_context> is non-empty and contains a distinct topic not already answered,
274-
END with a single sentence (no bullet):
275-
"Would you like to know about <a concise follow-up topic>?"
266+
Rules:
267+
- Always answer ONLY from <context> provided below.
268+
- Never use the web, external sources, or prior knowledge outside the given context.
269+
- Always consider query and answer in relevance to it.
270+
- Always follow below mentioned rules at all times :
271+
• Begin each answer with: **"According to <source>"** (extract filename from metadata if available).
272+
• Answer concisely in bullet and sub-bullet points.
273+
• Keep under 150 words.
274+
• Summarize meaningfully and in a perfect flow
275+
• Each bullet must be factual and context-bound.
276+
277+
- If correction (from reformulation step) is provided, prepend it before bullets.
278+
- Respect chat history for coherence.
279+
- Always include a follow up question if <context_followup> is non-empty in the format(without bullet points) "Would you like to know about <a follow up question from context_followup not overlapping with the answer generated>?"
276280
277281
<user_query>
278282
{query}
@@ -326,6 +330,7 @@ def medical_chatbot_pipeline(query, chat_history, retrieved_chunks, context_foll
326330
Chat history: {chat_history}
327331
Reply: """ )
328332

333+
329334
# ------------------ Router ------------------
330335
def route_intent(user_message: str):
331336
if not llm or not retriever:

new_architeture_v3.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,20 @@ def medical_chatbot_pipeline(query, chat_history, retrieved_chunks, context_foll
263263
answer_prompt = f"""
264264
You are a professional medical assistant.
265265
266-
Constraints:
267-
- Answer ONLY from <context>.
268-
- Use concise bullet points (sub-bullets allowed), ~150 words max.
269-
- Start with: "According to the retrieved source"
270-
- Be liberal: if the context and query share the core topic, answer from context even if not the exact angle.
271-
- Do not add external facts.
272-
273-
If <followup_context> is non-empty and contains a distinct topic not already answered,
274-
END with a single sentence (no bullet):
275-
"Would you like to know about <a concise follow-up topic>?"
266+
Rules:
267+
- Always answer ONLY from <context> provided below.
268+
- Never use the web, external sources, or prior knowledge outside the given context.
269+
- Always consider query and answer in relevance to it.
270+
- Always follow below mentioned rules at all times :
271+
• Begin each answer with: **"According to <source>"** (extract filename from metadata if available).
272+
• Answer concisely in bullet and sub-bullet points.
273+
• Keep under 150 words.
274+
• Summarize meaningfully and in a perfect flow
275+
• Each bullet must be factual and context-bound.
276+
277+
- If correction (from reformulation step) is provided, prepend it before bullets.
278+
- Respect chat history for coherence.
279+
- Always include a follow up question if <context_followup> is non-empty in the format(without bullet points) "Would you like to know about <a follow up question from context_followup not overlapping with the answer generated>?"
276280
277281
<user_query>
278282
{query}

0 commit comments

Comments
 (0)