Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,18 +7,22 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
@tool
|
| 13 |
-
def
|
| 14 |
-
"""
|
| 15 |
Args:
|
| 16 |
-
topic: The subject to
|
| 17 |
max_results: How many search results to include in the briefing (e.g. 3-10).
|
| 18 |
"""
|
| 19 |
search = DuckDuckGoSearchTool(max_results=max_results)
|
| 20 |
raw_results = search(topic)
|
| 21 |
-
return f"
|
| 22 |
|
| 23 |
@tool
|
| 24 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -49,15 +53,14 @@ custom_role_conversions=None,
|
|
| 49 |
)
|
| 50 |
|
| 51 |
|
| 52 |
-
|
| 53 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 54 |
|
| 55 |
with open("prompts.yaml", 'r') as stream:
|
| 56 |
prompt_templates = yaml.safe_load(stream)
|
| 57 |
|
| 58 |
agent = CodeAgent(
|
| 59 |
model=model,
|
| 60 |
-
tools=[final_answer,
|
| 61 |
max_steps=6,
|
| 62 |
verbosity_level=1,
|
| 63 |
grammar=None,
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
|
| 11 |
+
# Import tool from Hub
|
| 12 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 13 |
+
|
| 14 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 15 |
|
| 16 |
@tool
|
| 17 |
+
def search_web(topic: str, max_results: int = 5) -> str:
|
| 18 |
+
"""Search the web for pages that are related to the given topic.
|
| 19 |
Args:
|
| 20 |
+
topic: The subject to search, e.g. "fusion energy breakthroughs 2026".
|
| 21 |
max_results: How many search results to include in the briefing (e.g. 3-10).
|
| 22 |
"""
|
| 23 |
search = DuckDuckGoSearchTool(max_results=max_results)
|
| 24 |
raw_results = search(topic)
|
| 25 |
+
return f"Web searches for '{topic}':\n\n{raw_results}"
|
| 26 |
|
| 27 |
@tool
|
| 28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 53 |
)
|
| 54 |
|
| 55 |
|
| 56 |
+
|
|
|
|
| 57 |
|
| 58 |
with open("prompts.yaml", 'r') as stream:
|
| 59 |
prompt_templates = yaml.safe_load(stream)
|
| 60 |
|
| 61 |
agent = CodeAgent(
|
| 62 |
model=model,
|
| 63 |
+
tools=[final_answer,search_web,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 64 |
max_steps=6,
|
| 65 |
verbosity_level=1,
|
| 66 |
grammar=None,
|