natharzu commited on
Commit
ded42cc
·
verified ·
1 Parent(s): 044eba2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
 
2
  import datetime
3
  import requests
4
  import pytz
@@ -64,26 +65,31 @@ def weather_tool(agent_input: str) -> str:
64
  # Register the tool in Smolagents
65
  tool_1 = smolagents.Tool(name="FavoriteWeather", function=weather_tool)
66
 
 
 
 
 
 
67
  # Tool 2: Ask for favorite color and return a shape associated with it
68
- def color_shape_tool(agent_input: str):
69
  # Predefined colors and shapes (this can be expanded)
70
- color_to_shape = {
71
- "red": "circle",
72
- "blue": "square",
73
- "green": "triangle",
74
- "yellow": "rectangle",
75
- "purple": "pentagon"
76
- }
77
 
78
  # Find the corresponding shape for the favorite color
79
- color = agent_input.lower()
80
- if color in color_to_shape:
81
- return f"Your favorite color is {color}, and the shape associated with it is a {color_to_shape[color]}."
82
- else:
83
- return "Sorry, I don't know a shape for that color."
84
 
85
  # Register the tool in Smolagents
86
- tool_2 = smolagents.Tool(name="FavoriteColorShape", function=color_shape_tool)
87
 
88
  final_answer = FinalAnswerTool()
89
 
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
+ import smolagents # Make sure to import smolagents
3
  import datetime
4
  import requests
5
  import pytz
 
65
  # Register the tool in Smolagents
66
  tool_1 = smolagents.Tool(name="FavoriteWeather", function=weather_tool)
67
 
68
+ # Example usage (you can use this to test the tool)
69
+ agent = smolagents.Agent(tools=[tool_1])
70
+ response = agent.run("sunny")
71
+ print(response) # Should print the response for "sunny" weather
72
+
73
  # Tool 2: Ask for favorite color and return a shape associated with it
74
+ # def color_shape_tool(agent_input: str):
75
  # Predefined colors and shapes (this can be expanded)
76
+ # color_to_shape = {
77
+ # "red": "circle",
78
+ # "blue": "square",
79
+ # "green": "triangle",
80
+ # "yellow": "rectangle",
81
+ # "purple": "pentagon"
82
+ # }
83
 
84
  # Find the corresponding shape for the favorite color
85
+ # color = agent_input.lower()
86
+ # if color in color_to_shape:
87
+ # return f"Your favorite color is {color}, and the shape associated with it is a {color_to_shape[color]}."
88
+ # else:
89
+ # return "Sorry, I don't know a shape for that color."
90
 
91
  # Register the tool in Smolagents
92
+ #tool_2 = smolagents.Tool(name="FavoriteColorShape", function=color_shape_tool)
93
 
94
  final_answer = FinalAnswerTool()
95