jaidesign commited on
Commit
07cecdd
·
verified ·
1 Parent(s): 1677c7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -7
app.py CHANGED
@@ -8,14 +8,24 @@ from tools.final_answer import FinalAnswerTool
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 get_weather(location:str, zipcode: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 fetches the current weather in a specified location
15
  Args:
16
- location: A string representing a valid location (e.g., 'America/New_York').
17
- zipcode: An integer representing a valid zip code for this location (e.g., 'Franconia,VA/22310').
 
 
 
18
  """
 
 
 
 
 
 
19
  return f"The current weather in {location,zipcode} is: {temperature,}"
20
 
21
  @tool
@@ -33,17 +43,40 @@ 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
 
38
  final_answer = FinalAnswerTool()
39
 
40
  # 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:
41
- model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
42
 
43
  model = HfApiModel(
44
  max_tokens=2096,
45
  temperature=0.5,
46
  model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
 
47
  custom_role_conversions=None,
48
  )
49
 
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
+
12
  @tool
13
+ def get_weather(location: str = None, zipcode: int = None) -> str:
14
+ """Fetches the current weather for a specified location or zip code.
15
+
16
  Args:
17
+ location: A string representing a valid city name or region (e.g., 'New York').
18
+ zipcode: An integer representing a valid zip code (e.g., 10001 for NYC).
19
+
20
+ Returns:
21
+ A string describing the weather conditions, temperature, and humidity.
22
  """
23
+ temperature = data["main"]["temp"]
24
+ conditions = data["weather"][0]["description"]
25
+ humidity = data["main"]["humidity"]
26
+
27
+ return (f"🌤️ Weather in {location or zipcode}: {conditions.capitalize()}, "
28
+ f"Temperature: {temperature}°C, Humidity: {humidity}%")
29
  return f"The current weather in {location,zipcode} is: {temperature,}"
30
 
31
  @tool
 
43
  except Exception as e:
44
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
45
 
46
+
47
+ @tool
48
+ def getMarsWeather() -> str:
49
+ """
50
+ A tool that fetches the current weather on Mars using NASA's InSight API.
51
+ Returns:
52
+ A string containing the sol (Martian day), average temperature, and wind speed on Mars.
53
+ """
54
+ insightURL = 'https://api.nasa.gov/insight_weather/?api_key={}&feedtype=json&ver=1.0'.format(NASA_API_KEY)
55
+ response = requests.get(insightURL)
56
+ marsWeatherRaw = response.json()
57
+ firstKey = next(iter(marsWeatherRaw))
58
+ marsWeather = {
59
+ 'sol': firstKey,
60
+ 'temperature': marsWeatherRaw[firstKey]['AT']['av'],
61
+ 'wind_speed': marsWeatherRaw[firstKey]['HWS']['av']
62
+ }
63
+ outputStr = "The temperature on Mars on Sol {sol} is {temperature} C and wind speeds of {wind_speed} m/sec.".format(
64
+ sol=marsWeather['sol'],
65
+ temperature=marsWeather['temperature'],
66
+ wind_speed=marsWeather['wind_speed'])
67
+
68
+ return outputStr
69
 
70
  final_answer = FinalAnswerTool()
71
 
72
  # 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:
73
+ #model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
74
 
75
  model = HfApiModel(
76
  max_tokens=2096,
77
  temperature=0.5,
78
  model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
79
+ #model_id='meta-llama/Llama-3.2-3B-Instruct',# Here I used another model to compare the results
80
  custom_role_conversions=None,
81
  )
82