iProsto commited on
Commit
0b26969
·
verified ·
1 Parent(s): 8836d9e

Update app.py

Browse files

add iss location tool

Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -25,24 +25,33 @@ def get_list_of_people_on_iss() -> dict:
25
  response = requests.get(url)
26
 
27
  if response.status_code == 200:
28
- return response.text
29
  else:
30
  return f"Error fetching astronauts: {response.status_code}"
31
 
 
32
  @tool
33
- def get_current_time_in_timezone(timezone: str) -> str:
34
- """A tool that fetches the current local time in a specified timezone.
35
- Args:
36
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
 
 
 
 
 
 
 
 
37
  """
38
- try:
39
- # Create timezone object
40
- tz = pytz.timezone(timezone)
41
- # Get current time in that timezone
42
- local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
43
- return f"The current local time in {timezone} is: {local_time}"
44
- except Exception as e:
45
- return f"Error fetching time for timezone '{timezone}': {str(e)}"
46
 
47
 
48
  final_answer = FinalAnswerTool()
@@ -66,7 +75,7 @@ with open("prompts.yaml", 'r') as stream:
66
 
67
  agent = CodeAgent(
68
  model=model,
69
- tools=[final_answer, get_list_of_people_on_iss],
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,
 
25
  response = requests.get(url)
26
 
27
  if response.status_code == 200:
28
+ return response.json()
29
  else:
30
  return f"Error fetching astronauts: {response.status_code}"
31
 
32
+
33
  @tool
34
+ def get_iss_location() -> dict:
35
+ """A tool that fetches the current location of the International Space Station (ISS).
36
+
37
+ Returns:
38
+ dict: A JSON object containing the following keys:
39
+ - "message" (str): Status message (e.g., "success").
40
+ - "timestamp" (int): The UNIX timestamp when the location was recorded.
41
+ - "iss_position" (dict): The latitude and longitude of the ISS.
42
+ - "latitude" (str): The current latitude of the ISS.
43
+ - "longitude" (str): The current longitude of the ISS.
44
+
45
+ Args: None
46
  """
47
+
48
+ url = "http://api.open-notify.org/iss-now.json"
49
+ response = requests.get(url)
50
+
51
+ if response.status_code == 200:
52
+ return response.json()
53
+ else:
54
+ return f"Error fetching ISS location: {response.status_code}"
55
 
56
 
57
  final_answer = FinalAnswerTool()
 
75
 
76
  agent = CodeAgent(
77
  model=model,
78
+ tools=[final_answer, get_list_of_people_on_iss, get_iss_location],
79
  max_steps=6,
80
  verbosity_level=1,
81
  grammar=None,