Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234559 unmodified lines656667686970717273687475707172737475767677787980818283847980818283858687888990918692939495from 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 itdef color_shape_tool(agent_input: str):# 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" }# 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."# 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 Smolagentstool_2 = smolagents.Tool(name="FavoriteColorShape", function=color_shape_tool)#tool_2 = smolagents.Tool(name="FavoriteColorShape", function=color_shape_tool)
final_answer = FinalAnswerTool()
app.py+20-14