Spaces:
Sleeping
Sleeping
Upload agent.py
Browse files- api/agent.py +7 -1
api/agent.py
CHANGED
|
@@ -95,6 +95,12 @@ STRICT RESPONSE RULES — follow these exactly:
|
|
| 95 |
- If you have already asked a follow-up question in a previous turn, do NOT ask the same one again.
|
| 96 |
- After delivering clinical findings and recommendations, STOP. Do not append generic offers to help.
|
| 97 |
- If the patient answers "yes" to your follow-up question, move forward with the next clinical step — do NOT re-ask the same question.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
GREETING BEHAVIOUR:
|
| 100 |
- If the user sends a greeting (hi, hello, hey, thanks, ok, yes, no, good morning, etc.) with NO symptom content, DO NOT call any tools.
|
|
@@ -529,7 +535,7 @@ def chat(session_id: str, user_message: str, history: List[Dict]) -> str:
|
|
| 529 |
[SystemMessage(content=SYSTEM_PROMPT)]
|
| 530 |
+ lc_history
|
| 531 |
+ [AM(content=content)]
|
| 532 |
-
+ [HM(content="
|
| 533 |
)
|
| 534 |
final_response = llm.invoke(followup_messages)
|
| 535 |
return final_response.content if hasattr(final_response, "content") else str(final_response)
|
|
|
|
| 95 |
- If you have already asked a follow-up question in a previous turn, do NOT ask the same one again.
|
| 96 |
- After delivering clinical findings and recommendations, STOP. Do not append generic offers to help.
|
| 97 |
- If the patient answers "yes" to your follow-up question, move forward with the next clinical step — do NOT re-ask the same question.
|
| 98 |
+
- If the patient answers "no" to your follow-up question, acknowledge it briefly and move to a DIFFERENT follow-up question — do NOT repeat the same question or give the same response again.
|
| 99 |
+
- NEVER give the exact same response twice in a conversation under any circumstances.
|
| 100 |
+
- NEVER mention other diseases by name (e.g. Trigeminal Neuralgia, NMOSD, Lupus, Sarcoidosis, Vasculitis) in the chat response. Focus only on MS. If mimics must be excluded, say "we will run tests to rule out other conditions" — do not name them.
|
| 101 |
+
- Do NOT say "based on the search results" — respond as a clinician, not a search engine.
|
| 102 |
+
- Do NOT say "the tool output suggests" or "according to the tool" — integrate findings naturally into your clinical response.
|
| 103 |
+
- Each response must move the clinical conversation FORWARD. Never stay in the same place.
|
| 104 |
|
| 105 |
GREETING BEHAVIOUR:
|
| 106 |
- If the user sends a greeting (hi, hello, hey, thanks, ok, yes, no, good morning, etc.) with NO symptom content, DO NOT call any tools.
|
|
|
|
| 535 |
[SystemMessage(content=SYSTEM_PROMPT)]
|
| 536 |
+ lc_history
|
| 537 |
+ [AM(content=content)]
|
| 538 |
+
+ [HM(content="Clinical data:\n" + str(tool_result) + "\n\nRespond as a clinician. Do NOT say based on search results or the tool says. Do NOT mention other disease names. Move the assessment forward with one new focused follow-up question if needed.")]
|
| 539 |
)
|
| 540 |
final_response = llm.invoke(followup_messages)
|
| 541 |
return final_response.content if hasattr(final_response, "content") else str(final_response)
|