Spaces:
Running
Running
Revert
Browse files
app.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
-
from mcp import StdioServerParameters
|
3 |
import datetime
|
4 |
import requests
|
5 |
import pytz
|
6 |
import yaml
|
7 |
-
import os
|
8 |
from tools.final_answer import FinalAnswerTool
|
9 |
|
10 |
from Gradio_UI import GradioUI
|
@@ -36,12 +34,6 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
36 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
37 |
|
38 |
|
39 |
-
server_parameters = StdioServerParameters(
|
40 |
-
command="uv",
|
41 |
-
args=["--quiet", "[email protected]"],
|
42 |
-
env={"UV_PYTHON": "3.12", **os.environ},
|
43 |
-
)
|
44 |
-
|
45 |
final_answer = FinalAnswerTool()
|
46 |
|
47 |
# 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,32 +53,17 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
|
|
61 |
with open("prompts.yaml", 'r') as stream:
|
62 |
prompt_templates = yaml.safe_load(stream)
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
with ToolCollection.from_mcp(server_parameters) as tool_collection:
|
77 |
-
agent = CodeAgent(
|
78 |
-
model=model,
|
79 |
-
tools=[final_answer, *tool_collection.tools],
|
80 |
-
add_base_tools=True,
|
81 |
-
max_steps=6,
|
82 |
-
verbosity_level=1,
|
83 |
-
grammar=None,
|
84 |
-
planning_interval=None,
|
85 |
-
name=None,
|
86 |
-
description=None,
|
87 |
-
prompt_templates=prompt_templates
|
88 |
-
)
|
89 |
-
#agent.run("Please find a remedy for hangover.")
|
90 |
|
91 |
|
92 |
GradioUI(agent).launch()
|
|
|
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 |
|
8 |
from Gradio_UI import GradioUI
|
|
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
final_answer = FinalAnswerTool()
|
38 |
|
39 |
# 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:
|
|
|
53 |
with open("prompts.yaml", 'r') as stream:
|
54 |
prompt_templates = yaml.safe_load(stream)
|
55 |
|
56 |
+
agent = CodeAgent(
|
57 |
+
model=model,
|
58 |
+
tools=[final_answer, image_generation_tool], ## add your tools here (don't remove final answer)
|
59 |
+
max_steps=6,
|
60 |
+
verbosity_level=1,
|
61 |
+
grammar=None,
|
62 |
+
planning_interval=None,
|
63 |
+
name=None,
|
64 |
+
description=None,
|
65 |
+
prompt_templates=prompt_templates
|
66 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
|
69 |
GradioUI(agent).launch()
|