Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
import requests
|
4 |
-
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
|
@@ -9,14 +8,22 @@ 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 that does nothing yet
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +62,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,
|
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
import requests
|
|
|
4 |
import yaml
|
5 |
from tools.final_answer import FinalAnswerTool
|
6 |
|
|
|
8 |
|
9 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
10 |
@tool
|
11 |
+
def biological_term_category(biological_term: str)-> str: #it's import to specify the return type
|
12 |
+
"""A tool that takes a biological term as input, performs a web search and returns its category from a predefined list
|
|
|
13 |
Args:
|
14 |
+
biological term (str): A string representing a biological term
|
15 |
+
|
16 |
+
Returns:
|
17 |
+
str: The category of the biological term
|
18 |
"""
|
19 |
+
try:
|
20 |
+
search_tool = DuckDuckGoSearchTool()
|
21 |
+
query = f"What is the biological category for the {biological_term}?"
|
22 |
+
search_results = search_tool(query)
|
23 |
+
if search_results:
|
24 |
+
return search_results
|
25 |
+
else:
|
26 |
+
return f"I couldn't find the category for the {biological_term}."
|
27 |
|
28 |
@tool
|
29 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
62 |
|
63 |
agent = CodeAgent(
|
64 |
model=model,
|
65 |
+
tools=[final_answer, biological_term_category], ## add your tools here (don't remove final answer)
|
66 |
max_steps=6,
|
67 |
verbosity_level=1,
|
68 |
grammar=None,
|