hardknee commited on
Commit
0d42202
·
verified ·
1 Parent(s): 51bbc5b

Added Nasa Neo Tool

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -3,10 +3,32 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
 
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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import requests
7
  from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
10
 
11
+
12
+ @tool
13
+ def get_nasa_neo_data(start_date:str, end_date:str) -> dict:
14
+ """A function to get Near Earth Object (NEO) data from NASA API.
15
+ Args:
16
+ start_date (str): The start date of the data to be fetched.
17
+ end_date (str): The end date of the data to be fetched.
18
+ Returns: The data fetched from the API as a JSON-like dictionary.
19
+ """
20
+ root_url = "https://api.nasa.gov/neo/rest/v1/feed?"
21
+ api_key = os.getenv("NASA_API_KEY")
22
+ params = f"start_date={start_date}&end_date={end_date}&api_key={api_key}"
23
+ url = root_url + params
24
+ response = requests.get(url)
25
+ if repr(response.status_code) == "200":
26
+ data = response.json()
27
+ return data
28
+ else:
29
+ return f"Error: {response.status_code}")
30
+
31
+
32
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
33
  @tool
34
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type