Spaces:
Sleeping
Sleeping
Update app.py
Browse filesadd iss location tool
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.
|
| 29 |
else:
|
| 30 |
return f"Error fetching astronauts: {response.status_code}"
|
| 31 |
|
|
|
|
| 32 |
@tool
|
| 33 |
-
def
|
| 34 |
-
"""A tool that fetches the current
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
"""
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
return
|
| 44 |
-
|
| 45 |
-
return f"Error fetching
|
| 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,
|