gpaasch commited on
Commit
b31399c
·
1 Parent(s): cc35b42

1. Modified the query prompt to explicitly ask for differentiating questions

Browse files

2. Started with lower confidence (0.6) to reflect initial uncertainty
3. Used the query response to guide specific follow-up questions
4. Removed generic timing questions
5. Added structure to parse multiple potential diagnoses

Files changed (1) hide show
  1. src/app.py +13 -9
src/app.py CHANGED
@@ -145,16 +145,20 @@ def process_speech(new_transcript, history):
145
 
146
  try:
147
  # Query the symptom index with user's transcript
148
- response = symptom_index.as_query_engine().query(new_transcript)
 
 
 
149
 
150
- # Extract the ICD code and description
151
- icd_info = str(response).strip()
 
152
 
153
- # Structure the initial response
154
  formatted_response = {
155
- "diagnoses": [icd_info],
156
- "confidences": [0.8], # We could make this more dynamic
157
- "follow_up": f"Could you tell me more about your symptoms? When did they start?"
158
  }
159
 
160
  # Add to conversation history
@@ -163,9 +167,9 @@ def process_speech(new_transcript, history):
163
 
164
  except Exception as e:
165
  error_response = {
166
- "error": str(e),
167
  "status": "error",
168
- "transcript": new_transcript # Include what we heard for debugging
169
  }
170
  history.append({"role": "user", "content": new_transcript})
171
  history.append({"role": "assistant", "content": json.dumps(error_response, indent=2)})
 
145
 
146
  try:
147
  # Query the symptom index with user's transcript
148
+ response = symptom_index.as_query_engine().query(
149
+ f"""Based on this symptom description, list the top 2-3 most likely ICD-10 codes
150
+ and key differentiating questions we should ask: {new_transcript}"""
151
+ )
152
 
153
+ # Parse the response and structure initial findings
154
+ icd_codes = str(response).strip().split('\n')
155
+ primary_diagnosis = icd_codes[0] if icd_codes else "Unknown"
156
 
157
+ # Structure a response that includes specific follow-up
158
  formatted_response = {
159
+ "diagnoses": [primary_diagnosis],
160
+ "confidences": [0.6], # Start with moderate confidence
161
+ "follow_up": f"To differentiate between possible diagnoses, {icd_codes[1] if len(icd_codes) > 1 else 'please describe'}:"
162
  }
163
 
164
  # Add to conversation history
 
167
 
168
  except Exception as e:
169
  error_response = {
170
+ "error": str(e),
171
  "status": "error",
172
+ "transcript": new_transcript
173
  }
174
  history.append({"role": "user", "content": new_transcript})
175
  history.append({"role": "assistant", "content": json.dumps(error_response, indent=2)})