DenverJones commited on
Commit
1fddef8
·
verified ·
1 Parent(s): ea8c721

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -26
app.py CHANGED
@@ -10,15 +10,14 @@ def get_snowfall_forecast(city: str, date: str) -> str:
10
  """
11
  Retrieve the expected snowfall for a given city on a specific date.
12
 
13
- Parameters:
14
- city (str): The name of the city for which snowfall forecast is required.
15
- date (str): The date in YYYY-MM-DD format to check the snowfall forecast.
16
 
17
  Returns:
18
- str: A message stating the expected snowfall in centimeters or an error if data is unavailable.
19
  """
20
  try:
21
- # Get latitude and longitude of the city
22
  geo_url = f"https://geocoding-api.open-meteo.com/v1/search?name={city}&count=1&format=json"
23
  geo_response = requests.get(geo_url).json()
24
 
@@ -28,7 +27,6 @@ def get_snowfall_forecast(city: str, date: str) -> str:
28
  latitude = geo_response["results"][0]["latitude"]
29
  longitude = geo_response["results"][0]["longitude"]
30
 
31
- # Fetch snowfall forecast
32
  weather_url = f"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&daily=snowfall_sum&timezone=auto&start_date={date}&end_date={date}"
33
  weather_response = requests.get(weather_url).json()
34
 
@@ -41,23 +39,3 @@ def get_snowfall_forecast(city: str, date: str) -> str:
41
  except Exception as e:
42
  return f"Error retrieving snowfall forecast: {str(e)}"
43
 
44
- # ✅ Load the Final Answer Tool
45
- final_answer = FinalAnswerTool()
46
-
47
- # ✅ Load the Language Model
48
- model = HfApiModel(
49
- max_tokens=2096,
50
- temperature=0.5,
51
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
52
- )
53
-
54
- # ✅ Create the AI Agent with Tools
55
- agent = CodeAgent(
56
- model=model,
57
- tools=[final_answer, get_snowfall_forecast], # Added the snowfall forecast tool
58
- max_steps=6,
59
- verbosity_level=1,
60
- )
61
-
62
- # ✅ Launch the Gradio UI
63
- GradioUI(agent).launch()
 
10
  """
11
  Retrieve the expected snowfall for a given city on a specific date.
12
 
13
+ Args:
14
+ city (str): The name of the city.
15
+ date (str): The date in YYYY-MM-DD format.
16
 
17
  Returns:
18
+ str: The expected snowfall in centimeters or an error message.
19
  """
20
  try:
 
21
  geo_url = f"https://geocoding-api.open-meteo.com/v1/search?name={city}&count=1&format=json"
22
  geo_response = requests.get(geo_url).json()
23
 
 
27
  latitude = geo_response["results"][0]["latitude"]
28
  longitude = geo_response["results"][0]["longitude"]
29
 
 
30
  weather_url = f"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&daily=snowfall_sum&timezone=auto&start_date={date}&end_date={date}"
31
  weather_response = requests.get(weather_url).json()
32
 
 
39
  except Exception as e:
40
  return f"Error retrieving snowfall forecast: {str(e)}"
41