Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,15 +8,50 @@ from tools.final_answer import FinalAnswerTool
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
#
|
| 14 |
-
"""A tool
|
|
|
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +90,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
+
# @tool
|
| 12 |
+
# def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
| 13 |
+
# #Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
+
# """A tool that does nothing yet
|
| 15 |
+
# Args:
|
| 16 |
+
# arg1: the first argument
|
| 17 |
+
# arg2: the second argument
|
| 18 |
+
# """
|
| 19 |
+
# return "What magic will you build ?"
|
| 20 |
+
|
| 21 |
@tool
|
| 22 |
+
def med_tool(role: str, symptoms: str) -> str:
|
| 23 |
+
# It's important to specify the return type
|
| 24 |
+
"""A tool for symptom collection (nurse) and diagnosis (doctor).
|
| 25 |
+
|
| 26 |
Args:
|
| 27 |
+
role: The role of the healthcare provider ('nurse' or 'doctor')
|
| 28 |
+
symptoms: The symptoms described by the patient
|
| 29 |
+
|
| 30 |
+
Returns:
|
| 31 |
+
A response based on the role provided.
|
| 32 |
"""
|
| 33 |
+
|
| 34 |
+
if role.lower() == "nurse":
|
| 35 |
+
follow_up_questions = [
|
| 36 |
+
"How long have you had these symptoms?",
|
| 37 |
+
"Do you have any allergies?",
|
| 38 |
+
"Are you on any medication?",
|
| 39 |
+
"Have you had any recent illnesses?",
|
| 40 |
+
"Have you noticed any other unusual changes?"
|
| 41 |
+
]
|
| 42 |
+
return (f"Nurse: I have recorded the symptoms: {symptoms}.\n"
|
| 43 |
+
f"Here are some follow-up questions:\n- " + "\n- ".join(follow_up_questions))
|
| 44 |
+
|
| 45 |
+
elif role.lower() == "doctor":
|
| 46 |
+
# Delegating diagnosis to an external tool (e.g., AI search, RAG)
|
| 47 |
+
return (f"Doctor: Based on the symptoms: {symptoms}, I will now analyze the data.\n"
|
| 48 |
+
f"Fetching diagnosis, medication, and treatment recommendations from the medical database...")
|
| 49 |
+
|
| 50 |
+
else:
|
| 51 |
+
return "Invalid role! Please specify either 'nurse' or 'doctor'."
|
| 52 |
+
|
| 53 |
+
final_answer = FinalAnswerTool()
|
| 54 |
+
search_tool = DuckDuckGoSearchTool()
|
| 55 |
|
| 56 |
@tool
|
| 57 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 90 |
|
| 91 |
agent = CodeAgent(
|
| 92 |
model=model,
|
| 93 |
+
tools=[final_answer, med_tool], ## add your tools here (don't remove final answer)
|
| 94 |
max_steps=6,
|
| 95 |
verbosity_level=1,
|
| 96 |
grammar=None,
|