mugwaneza commited on
Commit
9f98750
·
verified ·
1 Parent(s): 8121d10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -2
app.py CHANGED
@@ -4,19 +4,44 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
 
 
 
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
  """A tool that does nothing yet
15
  Args:
16
  arg1: the first argument
17
  arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -66,4 +91,8 @@ agent = CodeAgent(
66
  )
67
 
68
 
 
 
 
 
69
  GradioUI(agent).launch()
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ #These are waether specific imports
8
+ import openmeteo_requests
9
+ import pandas as pd
10
+ import requests_cache
11
+ from retry_requests import retry
12
 
13
  from Gradio_UI import GradioUI
14
 
15
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
16
  @tool
17
+ def houry_templature(arg1:str, arg2:int)-> str: #it's import to specify the return type
18
  #Keep this format for the description / args / args description but feel free to modify the tool
19
  """A tool that does nothing yet
20
  Args:
21
  arg1: the first argument
22
  arg2: the second argument
23
  """
24
+ # Setup the Open-Meteo API client with cache and retry on error
25
+ cache_session = requests_cache.CachedSession('.cache', expire_after = 3600)
26
+ retry_session = retry(cache_session, retries = 5, backoff_factor = 0.2)
27
+ openmeteo = openmeteo_requests.Client(session = retry_session)
28
+
29
+ # Make sure all required weather variables are listed here
30
+ # The order of variables in hourly or daily is important to assign them correctly below
31
+ url = "https://api.open-meteo.com/v1/forecast"
32
+ params = {
33
+ "latitude": arg1,
34
+ "longitude": arg2,
35
+ "hourly": "temperature_2m",
36
+ }
37
+ responses = openmeteo.weather_api(url, params=params)
38
+
39
+ hourly = response.Hourly()
40
+ hourly_temperature_2m = hourly.Variables(0).ValuesAsNumpy()
41
+
42
+
43
+
44
+ return hourly_data["temperature_2m"] = hourly_temperature_2m
45
 
46
  @tool
47
  def get_current_time_in_timezone(timezone: str) -> str:
 
91
  )
92
 
93
 
94
+ houry_templature(32.9,15,7)
95
+
96
+
97
+
98
  GradioUI(agent).launch()