Update src/model.py
Browse files- src/model.py +12 -8
src/model.py
CHANGED
|
@@ -1246,9 +1246,9 @@ def parse_doctor_response(response_text):
|
|
| 1246 |
questions.append(cleaned_item)
|
| 1247 |
parsed["follow_up_questions"] = questions
|
| 1248 |
else:
|
| 1249 |
-
#
|
| 1250 |
cleaned_text = re.sub(r'^\s*\*\*\s*|\s*\*\*\s*$', '', follow_up_text)
|
| 1251 |
-
parsed["follow_up_questions"] = [
|
| 1252 |
|
| 1253 |
# Try to extract reasoning if present
|
| 1254 |
reasoning_match = re.search(r'(?i)reasoning:?\s*(.*?)(?:\n\n\Z|\n(?:sources|follow)|\Z)', response_text, re.DOTALL)
|
|
@@ -1280,9 +1280,9 @@ def parse_doctor_response(response_text):
|
|
| 1280 |
|
| 1281 |
parsed["reasoning"] = reasoning_points
|
| 1282 |
else:
|
| 1283 |
-
# If
|
| 1284 |
cleaned_text = re.sub(r'^\s*\*\*\s*|\s*\*\*\s*$', '', reasoning_text)
|
| 1285 |
-
parsed["reasoning"] = [
|
| 1286 |
|
| 1287 |
# Extract sources/references
|
| 1288 |
sources_match = re.search(r'(?i)(sources|references):?\s*(.*?)(?:\n\n\Z|\Z)', response_text, re.DOTALL)
|
|
@@ -1467,12 +1467,16 @@ def orchestrator_chat(history, query, use_rag, is_follow_up=False):
|
|
| 1467 |
3. Recommendations for a treatment plan or next steps.
|
| 1468 |
|
| 1469 |
**After your main response, ALWAYS include these sections:**
|
| 1470 |
-
- **Follow-up Questions**:
|
| 1471 |
-
|
|
|
|
|
|
|
| 1472 |
|
| 1473 |
**IMPORTANT FORMATTING NOTES:**
|
| 1474 |
-
1.
|
| 1475 |
-
2.
|
|
|
|
|
|
|
| 1476 |
|
| 1477 |
IMPORTANT: Since database search is disabled, do not include citations or sources in your response.
|
| 1478 |
"""
|
|
|
|
| 1246 |
questions.append(cleaned_item)
|
| 1247 |
parsed["follow_up_questions"] = questions
|
| 1248 |
else:
|
| 1249 |
+
# Just use the raw text if no clear list format is detected
|
| 1250 |
cleaned_text = re.sub(r'^\s*\*\*\s*|\s*\*\*\s*$', '', follow_up_text)
|
| 1251 |
+
parsed["follow_up_questions"] = [cleaned_text]
|
| 1252 |
|
| 1253 |
# Try to extract reasoning if present
|
| 1254 |
reasoning_match = re.search(r'(?i)reasoning:?\s*(.*?)(?:\n\n\Z|\n(?:sources|follow)|\Z)', response_text, re.DOTALL)
|
|
|
|
| 1280 |
|
| 1281 |
parsed["reasoning"] = reasoning_points
|
| 1282 |
else:
|
| 1283 |
+
# If there are no bullet points, still clean up any markdown
|
| 1284 |
cleaned_text = re.sub(r'^\s*\*\*\s*|\s*\*\*\s*$', '', reasoning_text)
|
| 1285 |
+
parsed["reasoning"] = [cleaned_text]
|
| 1286 |
|
| 1287 |
# Extract sources/references
|
| 1288 |
sources_match = re.search(r'(?i)(sources|references):?\s*(.*?)(?:\n\n\Z|\Z)', response_text, re.DOTALL)
|
|
|
|
| 1467 |
3. Recommendations for a treatment plan or next steps.
|
| 1468 |
|
| 1469 |
**After your main response, ALWAYS include these sections:**
|
| 1470 |
+
- **Follow-up Questions**: Specific questions to gather additional information, numbered starting from 1 (not bullet points).
|
| 1471 |
+
Do NOT start the first question with asterisks (**). Format each question properly with just a number.
|
| 1472 |
+
- **Reasoning**: Provide a detailed, in-depth explanation of your clinical reasoning. Use bullet points for clarity. Aim for comprehensive insights that would be valuable to a healthcare professional.
|
| 1473 |
+
Do NOT start the first bullet point with asterisks (**). Format each point properly.
|
| 1474 |
|
| 1475 |
**IMPORTANT FORMATTING NOTES:**
|
| 1476 |
+
1. For follow-up questions, use numbered format (1. 2. 3.) not bullet points.
|
| 1477 |
+
2. Number the follow-up questions starting from 1, not from any other number.
|
| 1478 |
+
3. NEVER use markdown formatting like ** (asterisks) at the beginning of any points, questions, or lines.
|
| 1479 |
+
4. Make sure all bullet points and numbered items are clean, with no markdown formatting.
|
| 1480 |
|
| 1481 |
IMPORTANT: Since database search is disabled, do not include citations or sources in your response.
|
| 1482 |
"""
|