Aktraiser commited on
Commit
6d8e585
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -34,6 +34,31 @@ def get_current_time_in_timezone(timezone: str) -> str:
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:
 
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
 
37
+ @tool
38
+ def getMarsWeather() -> str:
39
+ """
40
+ A tool that fetches the current weather on Mars using NASA's InSight API.
41
+ Returns:
42
+ A string containing the sol (Martian day), average temperature, and wind speed on Mars.
43
+ """
44
+ myAPIkey = '7k4hKSUeWkbigKxZiNV5CQ8RSlEd72Cj'
45
+ insightURL = 'https://api.apilayer.com/therundown/affiliates'.format(myAPIkey)
46
+ response = requests.get(insightURL)
47
+ marsWeatherRaw = response.json()
48
+ firstKey = next(iter(marsWeatherRaw))
49
+ marsWeather = {
50
+ 'sol': firstKey,
51
+ 'temperature': marsWeatherRaw[firstKey]['AT']['av'],
52
+ 'wind_speed': marsWeatherRaw[firstKey]['HWS']['av']
53
+ }
54
+ outputStr = "The temperature on Mars on Sol {sol} is {temperature} C and wind speeds of {wind_speed} m/sec.".format(
55
+ sol=marsWeather['sol'],
56
+ temperature=marsWeather['temperature'],
57
+ wind_speed=marsWeather['wind_speed'])
58
+
59
+ return outputStr
60
+
61
+
62
  final_answer = FinalAnswerTool()
63
 
64
  # 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: