Spaces:
Sleeping
Sleeping
Update app.py
Browse files3 unmodified lines456789101112131415161718192021222324252612 unmodified lines394041424344454614 unmodified lines616263646566673 unmodified linesimport pytzimport yamlfrom tools.final_answer import FinalAnswerToolfrom tools.visit_webpage import VisitWebpageToolfrom tools.web_search import DuckDuckGoSearchToolfrom Gradio_UI import GradioUI@tooldef get_top_keywods_by_city(city: str, time: int) -> list[str]:"""A tool that returns a list with top 5 most popular things to do based on the cityArgs:city: A string representing a citytime: A timestamp representing a current time in a city"""print(city, time)if city == "Athens":return ["Acropolis", "Philosofy", "Sea", "Food", "Drinks"]return ["Other"]@tooldef get_current_time_in_timezone(timezone: str) -> str:12 unmodified linesfinal_answer = FinalAnswerTool()visit_webpage = VisitWebpageTool()web_search = DuckDuckGoSearchTool()# 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:# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'14 unmodified linesagent = CodeAgent(model=model,tools=[get_current_time_in_timezone, get_top_keywods_by_city, web_search, visit_webpage, final_answer], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,3 unmodified lines4567891011121314151617181920212223242526272829303112 unmodified lines44454647484914 unmodified lines646566676869703 unmodified linesimport pytzimport yamlfrom tools.final_answer import FinalAnswerToolfrom Gradio_UI import GradioUI@tooldef get_weather(city: str) -> str:"""Fetches current weather information for a specified city.Args:city: Name of the city (e.g., 'Paris')."""try:api_key = "your_openweathermap_api_key"response = requests.get(f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric")data = response.json()if data.get("cod") != 200:return f"Could not fetch weather: {data.get('message', 'Unknown error')}"temp = data['main']['temp']condition = data['weather'][0]['description']return f"Current weather in {city}: {temp}°C, {condition}."except Exception as e:return f"Error fetching weather: {str(e)}"@tooldef get_current_time_in_timezone(timezone: str) -> str:12 unmodified linesfinal_answer = FinalAnswerTool()# 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:# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'14 unmodified linesagent = CodeAgent(model=model,tools=[get_current_time_in_timezone, get_weather, final_answer], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,
app.py+17-14