Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -9,7 +9,7 @@ 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(
|
| 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:
|
|
@@ -56,6 +56,9 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 56 |
|
| 57 |
|
| 58 |
final_answer = FinalAnswerTool()
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 61 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
@@ -68,15 +71,12 @@ custom_role_conversions=None,
|
|
| 68 |
)
|
| 69 |
|
| 70 |
|
| 71 |
-
# Import tool from Hub
|
| 72 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 73 |
-
|
| 74 |
with open("prompts.yaml", 'r') as stream:
|
| 75 |
prompt_templates = yaml.safe_load(stream)
|
| 76 |
|
| 77 |
agent = CodeAgent(
|
| 78 |
model=model,
|
| 79 |
-
tools=[final_answer,food_nutrition], ## add your tools here (don't remove final answer)
|
| 80 |
max_steps=6,
|
| 81 |
verbosity_level=1,
|
| 82 |
grammar=None,
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool,VisitWebpageTool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
# @tool
|
| 12 |
+
# def my_custom_tool(: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:
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
final_answer = FinalAnswerTool()
|
| 59 |
+
web_search = DuckDuckGoSearchTool(max_results=3)
|
| 60 |
+
web_scrapper = VisitWebPageTool()
|
| 61 |
+
|
| 62 |
|
| 63 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 64 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
|
| 71 |
)
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
| 74 |
with open("prompts.yaml", 'r') as stream:
|
| 75 |
prompt_templates = yaml.safe_load(stream)
|
| 76 |
|
| 77 |
agent = CodeAgent(
|
| 78 |
model=model,
|
| 79 |
+
tools=[final_answer,food_nutrition,web_search,get_current_time_in_timezone,web_scrapper], ## add your tools here (don't remove final answer)
|
| 80 |
max_steps=6,
|
| 81 |
verbosity_level=1,
|
| 82 |
grammar=None,
|