ZeroNinerOne commited on
Commit
f88b1bf
Β·
verified Β·
1 Parent(s): 9914ebe

Upload agent.py

Browse files
Files changed (1) hide show
  1. api/agent.py +7 -4
api/agent.py CHANGED
@@ -97,10 +97,13 @@ STRICT RESPONSE RULES β€” follow these exactly:
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,7 +538,7 @@ def chat(session_id: str, user_message: str, history: List[Dict]) -> str:
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)
 
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, MOGAD, Lupus, Sarcoidosis, Vasculitis, NMO, AQP4, MOG-IgG) 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" or "I've searched the clinical knowledge base" β€” respond as a clinician, not a search engine.
102
+ - Do NOT say "the tool output suggests", "according to the tool", "the search results highlight" β€” integrate findings naturally.
103
  - Each response must move the clinical conversation FORWARD. Never stay in the same place.
104
+ - MAXIMUM 5 follow-up questions per conversation. After 5 "no" answers with no MS symptoms found, conclude clearly that the symptoms described are NOT consistent with MS and suggest the patient see a general practitioner for their actual complaint.
105
+ - If the patient describes ONLY non-neurological symptoms (fever, cough, cold, stomach pain, headache alone, nausea, vomiting, diarrhoea, rash, etc.) with NO neurological component, respond immediately: acknowledge their symptom, explain NeuroCheck specialises in MS and neurological symptoms only, and advise them to consult a general practitioner. Do NOT keep asking MS-specific follow-up questions.
106
+ - Non-neurological symptoms that should trigger immediate GP redirect: fever, cough, cold, flu, nausea, vomiting, diarrhoea, stomach pain, chest infection, sore throat, skin rash, ear pain, toothache, back pain without neurological features.
107
 
108
  GREETING BEHAVIOUR:
109
  - 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.
 
538
  [SystemMessage(content=SYSTEM_PROMPT)]
539
  + lc_history
540
  + [AM(content=content)]
541
+ + [HM(content="Clinical data:\n" + str(tool_result) + "\n\nRespond as a clinician. Rules: (1) Do NOT say based on search results or I searched the knowledge base. (2) Do NOT name any diseases other than MS. (3) If symptoms are non-neurological like fever or cough, immediately tell the patient NeuroCheck specialises in MS and refer them to a GP. (4) If no MS features found after thorough questioning, conclude clearly. (5) Move assessment forward β€” never repeat the same question.")]
542
  )
543
  final_response = llm.invoke(followup_messages)
544
  return final_response.content if hasattr(final_response, "content") else str(final_response)