Spaces:
Sleeping
Sleeping
Update app.py
Browse filesMade edits on diagnose_patient
app.py
CHANGED
|
@@ -59,25 +59,24 @@ def collect_symptoms(patient_id: str, symptoms: str) -> str:
|
|
| 59 |
return f"Unexpected Error: {str(e)}"
|
| 60 |
|
| 61 |
@tool
|
| 62 |
-
def diagnose_patient(
|
| 63 |
"""
|
| 64 |
Doctor tool to diagnose the patient based on symptoms.
|
| 65 |
-
|
| 66 |
Args:
|
| 67 |
-
self: Reference to the instance of the class.
|
| 68 |
patient_id: Unique identifier for the patient.
|
| 69 |
-
|
| 70 |
Returns:
|
| 71 |
Diagnosis and recommendations.
|
| 72 |
"""
|
| 73 |
try:
|
| 74 |
-
if patient_id not in
|
| 75 |
raise ValueError("No symptoms found. Nurse must collect symptoms first.")
|
| 76 |
|
| 77 |
-
symptoms =
|
| 78 |
-
diagnosis =
|
| 79 |
-
medication =
|
| 80 |
-
advice =
|
| 81 |
|
| 82 |
return (f"Doctor: Based on the symptoms: {symptoms},\n"
|
| 83 |
f"Diagnosis: {diagnosis}\n"
|
|
@@ -89,6 +88,7 @@ def diagnose_patient(self: CodeAgent, patient_id: str) -> str:
|
|
| 89 |
except Exception as e:
|
| 90 |
return f"Unexpected Error: {str(e)}"
|
| 91 |
|
|
|
|
| 92 |
@tool
|
| 93 |
def fetch_diagnosis(symptoms: str) -> str:
|
| 94 |
"""
|
|
|
|
| 59 |
return f"Unexpected Error: {str(e)}"
|
| 60 |
|
| 61 |
@tool
|
| 62 |
+
def diagnose_patient(patient_id: str) -> str:
|
| 63 |
"""
|
| 64 |
Doctor tool to diagnose the patient based on symptoms.
|
| 65 |
+
|
| 66 |
Args:
|
|
|
|
| 67 |
patient_id: Unique identifier for the patient.
|
| 68 |
+
|
| 69 |
Returns:
|
| 70 |
Diagnosis and recommendations.
|
| 71 |
"""
|
| 72 |
try:
|
| 73 |
+
if patient_id not in CodeAgent.patient_data:
|
| 74 |
raise ValueError("No symptoms found. Nurse must collect symptoms first.")
|
| 75 |
|
| 76 |
+
symptoms = CodeAgent.patient_data[patient_id]["symptoms"]
|
| 77 |
+
diagnosis = CodeAgent.fetch_diagnosis(symptoms)
|
| 78 |
+
medication = CodeAgent.fetch_medication(symptoms)
|
| 79 |
+
advice = CodeAgent.fetch_treatment_advice(symptoms)
|
| 80 |
|
| 81 |
return (f"Doctor: Based on the symptoms: {symptoms},\n"
|
| 82 |
f"Diagnosis: {diagnosis}\n"
|
|
|
|
| 88 |
except Exception as e:
|
| 89 |
return f"Unexpected Error: {str(e)}"
|
| 90 |
|
| 91 |
+
|
| 92 |
@tool
|
| 93 |
def fetch_diagnosis(symptoms: str) -> str:
|
| 94 |
"""
|