Spaces:
Running
Running
system prompt needed improvement
Browse files- app.py +7 -3
- services/prompt.py +0 -8
app.py
CHANGED
@@ -40,10 +40,15 @@ print("Symptom index built successfully. Ready for queries.", flush=True)
|
|
40 |
SYSTEM_PROMPT = (
|
41 |
"You are a medical assistant helping a user find the most relevant ICD-10 code based on their symptoms.\n",
|
42 |
"At each turn, determine the top three most relevant ICD-10 codes based on input from the user.\n",
|
43 |
-
"
|
44 |
-
"
|
45 |
"Replace low-confidence codes with new ones as you learn more.\n",
|
46 |
"Your goal is to find the most relevant codes with high confidence.\n",
|
|
|
|
|
|
|
|
|
|
|
47 |
)
|
48 |
|
49 |
# ========== Generator handler ==========
|
@@ -99,7 +104,6 @@ def on_submit(symptoms_text, history):
|
|
99 |
f"User symptoms: '{cleaned}'",
|
100 |
f"Relevant ICD-10 context:\n{context_text}",
|
101 |
"Respond with your top 3 ICD-10 codes and their confidence scores.",
|
102 |
-
"Think step by step and explain your reasoning."
|
103 |
])
|
104 |
|
105 |
msg = "✏️ Prompt built"
|
|
|
40 |
SYSTEM_PROMPT = (
|
41 |
"You are a medical assistant helping a user find the most relevant ICD-10 code based on their symptoms.\n",
|
42 |
"At each turn, determine the top three most relevant ICD-10 codes based on input from the user.\n",
|
43 |
+
"Assign a confidence score from 1 to 100 for each code you decided was relevant.\n",
|
44 |
+
"Asking a question to the user to raise or lower your confidence score for each code.\n",
|
45 |
"Replace low-confidence codes with new ones as you learn more.\n",
|
46 |
"Your goal is to find the most relevant codes with high confidence.\n",
|
47 |
+
"When you have high confidence in a code, provide it to the user.\n",
|
48 |
+
"Maintain a conversational tone and explain your reasoning step by step.\n",
|
49 |
+
"If you need more information, ask the user clarifying questions.\n",
|
50 |
+
"End your response with a summary of the top codes and their confidence scores.\n",
|
51 |
+
"If you need to ask the user a follow-up question, do so clearly.\n",
|
52 |
)
|
53 |
|
54 |
# ========== Generator handler ==========
|
|
|
104 |
f"User symptoms: '{cleaned}'",
|
105 |
f"Relevant ICD-10 context:\n{context_text}",
|
106 |
"Respond with your top 3 ICD-10 codes and their confidence scores.",
|
|
|
107 |
])
|
108 |
|
109 |
msg = "✏️ Prompt built"
|
services/prompt.py
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
# services/prompt.py
|
2 |
-
|
3 |
-
SYSTEM_PROMPT = """
|
4 |
-
You are a medical assistant helping a user narrow down to the most likely ICD-10 code.
|
5 |
-
At each turn, EITHER ask one focused clarifying question (e.g. "Is your cough dry or productive?")
|
6 |
-
or, if you have enough info, output a final JSON with fields:
|
7 |
-
{"diagnoses":[…], "confidences":[…]}.
|
8 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|