ninooo96 commited on
Commit
15d0377
·
verified ·
1 Parent(s): 8fe186c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -33,7 +33,19 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
-
 
 
 
 
 
 
 
 
 
 
 
 
37
  final_answer = FinalAnswerTool()
38
 
39
  # 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:
@@ -55,7 +67,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def get_weather(city: str) -> str:
38
+ """A tool that fetches the current weather of a specified city.
39
+ Args:
40
+ city: A string representing a city
41
+ """
42
+ url = f"https://wttr.in/{city}?format=3" # Formato compatto
43
+ response = requests.get(url)
44
+ if response.status_code == 200:
45
+ return f"The current weather on {city} is {response.text}"
46
+ else:
47
+ return "Error on fetching weather data."
48
+
49
  final_answer = FinalAnswerTool()
50
 
51
  # 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:
 
67
 
68
  agent = CodeAgent(
69
  model=model,
70
+ tools=[final_answer, get_current_time_in_timezone, get_weather], ## add your tools here (don't remove final answer)
71
  max_steps=6,
72
  verbosity_level=1,
73
  grammar=None,