Spaces:
Runtime error
Runtime error
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
|
|
@@ -10,8 +10,16 @@ from Gradio_UI import GradioUI
|
|
| 10 |
|
| 11 |
@tool
|
| 12 |
def get_weather(city: str) -> str:
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
demo = gr.Interface(fn=get_weather, inputs="text", outputs="text")
|
| 17 |
demo.launch()
|
|
@@ -51,6 +59,17 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
|
|
| 51 |
|
| 52 |
with open("prompts.yaml", 'r') as stream:
|
| 53 |
prompt_templates = yaml.safe_load(stream)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
agent = CodeAgent(
|
| 56 |
model=model,
|
|
@@ -63,6 +82,10 @@ agent = CodeAgent(
|
|
| 63 |
description=None,
|
| 64 |
prompt_templates=prompt_templates
|
| 65 |
)
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,get_weather,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 10 |
|
| 11 |
@tool
|
| 12 |
def get_weather(city: str) -> str:
|
| 13 |
+
"""
|
| 14 |
+
Retrieves the current weather for a given city.
|
| 15 |
+
|
| 16 |
+
Args:
|
| 17 |
+
city (str): Name of the city to get weather for.
|
| 18 |
+
|
| 19 |
+
Returns:
|
| 20 |
+
str: Weather description for the city.
|
| 21 |
+
"""
|
| 22 |
+
return f"Demo response for {city}
|
| 23 |
|
| 24 |
demo = gr.Interface(fn=get_weather, inputs="text", outputs="text")
|
| 25 |
demo.launch()
|
|
|
|
| 59 |
|
| 60 |
with open("prompts.yaml", 'r') as stream:
|
| 61 |
prompt_templates = yaml.safe_load(stream)
|
| 62 |
+
|
| 63 |
+
# registry.py
|
| 64 |
+
from tools import get_weather, get_current_time_in_timezone
|
| 65 |
+
from tools.final_answer import FinalAnswerTool
|
| 66 |
+
from smolagents import load_tool
|
| 67 |
+
|
| 68 |
+
tool_registry = {
|
| 69 |
+
"get_weather": {
|
| 70 |
+
"tool": get_weather,
|
| 71 |
+
"schema": get_weather.tool_schema(),
|
| 72 |
+
"enabled": True
|
| 73 |
|
| 74 |
agent = CodeAgent(
|
| 75 |
model=model,
|
|
|
|
| 82 |
description=None,
|
| 83 |
prompt_templates=prompt_templates
|
| 84 |
)
|
| 85 |
+
# app.py
|
| 86 |
+
from agent_setup import agent
|
| 87 |
+
from Gradio_UI import GradioUI
|
| 88 |
|
| 89 |
+
if __name__ == "__main__":
|
| 90 |
+
print("Launching DTstudios demo agent...")
|
| 91 |
+
GradioUI(agent).launch()
|