Spaces:
Sleeping
Sleeping
Update app.py
Browse files123459 unmodified lines6465666768697071727374757677787980818283848586878889from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,toolimport datetimeimport requestsimport pytz59 unmodified lines# Register the tool in Smolagentstool_1 = smolagents.Tool(name="FavoriteWeather", function=weather_tool)# Tool 2: Ask for favorite color and return a shape associated with itdef color_shape_tool(agent_input: str):# Predefined colors and shapes (this can be expanded)color_to_shape = {"red": "circle","blue": "square","green": "triangle","yellow": "rectangle","purple": "pentagon"}# Find the corresponding shape for the favorite colorcolor = agent_input.lower()if color in color_to_shape:return f"Your favorite color is {color}, and the shape associated with it is a {color_to_shape[color]}."else:return "Sorry, I don't know a shape for that color."# Register the tool in Smolagentstool_2 = smolagents.Tool(name="FavoriteColorShape", function=color_shape_tool)final_answer = FinalAnswerTool()1234559 unmodified lines65666768697071727374757677787980818283848586878889909192939495from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,toolimport smolagents # Make sure to import smolagentsimport datetimeimport requestsimport pytz59 unmodified lines# Register the tool in Smolagentstool_1 = smolagents.Tool(name="FavoriteWeather", function=weather_tool)# Example usage (you can use this to test the tool)agent = smolagents.Agent(tools=[tool_1])response = agent.run("sunny")print(response) # Should print the response for "sunny" weather# Tool 2: Ask for favorite color and return a shape associated with it# def color_shape_tool(agent_input: str):# Predefined colors and shapes (this can be expanded)# color_to_shape = {# "red": "circle",# "blue": "square",# "green": "triangle",# "yellow": "rectangle",# "purple": "pentagon"# }# Find the corresponding shape for the favorite color# color = agent_input.lower()# if color in color_to_shape:# return f"Your favorite color is {color}, and the shape associated with it is a {color_to_shape[color]}."# else:# return "Sorry, I don't know a shape for that color."# Register the tool in Smolagents#tool_2 = smolagents.Tool(name="FavoriteColorShape", function=color_shape_tool)final_answer = FinalAnswerTool()
app.py+20-14