Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,41 @@ 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 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
Args:
|
| 16 |
-
arg1:
|
| 17 |
-
arg2:
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +82,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer,
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 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 |
+
@tool
|
| 21 |
+
def my_custom_tool(arg1: str, arg2: int) -> str: # it's important to specify the return type
|
| 22 |
+
"""A tool that fetches datasets related to body parts or medical imaging types (e.g., skin, brain, MRI, CT, etc.) from Hugging Face.
|
| 23 |
+
|
| 24 |
Args:
|
| 25 |
+
arg1: A body part or imaging modality keyword (e.g., 'skin', 'brain', 'XRay', 'ultrasound').
|
| 26 |
+
arg2: Maximum number of datasets to return.
|
| 27 |
"""
|
| 28 |
+
try:
|
| 29 |
+
query = arg1.lower()
|
| 30 |
+
limit = int(arg2)
|
| 31 |
+
|
| 32 |
+
response = requests.get(
|
| 33 |
+
f"https://huggingface.co/api/datasets?search={query}&limit={limit}"
|
| 34 |
+
)
|
| 35 |
+
response.raise_for_status()
|
| 36 |
+
datasets = response.json()
|
| 37 |
+
|
| 38 |
+
if not datasets:
|
| 39 |
+
return f"No datasets found for '{arg1}'."
|
| 40 |
+
|
| 41 |
+
results = [f"- {ds.get('id', 'Unknown')}" for ds in datasets[:limit]]
|
| 42 |
+
return f"Datasets related to '{arg1}':\n" + "\n".join(results)
|
| 43 |
+
|
| 44 |
+
except Exception as e:
|
| 45 |
+
return f"Error fetching datasets for '{arg1}': {str(e)}"
|
| 46 |
+
|
| 47 |
|
| 48 |
@tool
|
| 49 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 82 |
|
| 83 |
agent = CodeAgent(
|
| 84 |
model=model,
|
| 85 |
+
tools=[final_answer,my_custom_tool], ## add your tools here (don't remove final answer)
|
| 86 |
max_steps=6,
|
| 87 |
verbosity_level=1,
|
| 88 |
grammar=None,
|