Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,37 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
23 |
"""A tool that fetches the current local time in a specified timezone.
|
@@ -52,7 +83,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
52 |
|
53 |
agent = CodeAgent(
|
54 |
model=model,
|
55 |
-
tools=[final_answer, duckduckgo_search_tool, get_current_time_in_timezone, image_generation_tool], ## add your tools here (don't remove final answer)
|
56 |
max_steps=6,
|
57 |
verbosity_level=1,
|
58 |
grammar=None,
|
|
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
20 |
|
21 |
+
|
22 |
+
@tool
|
23 |
+
def get_nasa_info(date: str) -> str:
|
24 |
+
"""
|
25 |
+
Get a NASA image and its description for a specific date
|
26 |
+
Gccepts dates with 'yyyy-mm-dd' format and returns image link and description for nasa images
|
27 |
+
Args:
|
28 |
+
date: A string input representing the desired date in 'YYYY-MM-DD' format.
|
29 |
+
Returns:
|
30 |
+
A string containing the image URL and a description of the image, or an error message if something goes wrong.
|
31 |
+
"""
|
32 |
+
|
33 |
+
# Construct the API URL with the provided date and the DEMO_KEY.
|
34 |
+
api_url = f"https://api.nasa.gov/planetary/apod?date={date}&api_key=DEMO_KEY"
|
35 |
+
|
36 |
+
try:
|
37 |
+
response = requests.get(api_url)
|
38 |
+
response.raise_for_status()
|
39 |
+
data = response.json()
|
40 |
+
|
41 |
+
# Extract the image URL and description (explanation) from the API response.
|
42 |
+
image_url = data.get("url", "No image URL available")
|
43 |
+
description = data.get("explanation", "No description available")
|
44 |
+
|
45 |
+
result = f"Image URL: {image_url}\n\nDescription: {description}"
|
46 |
+
except Exception as e:
|
47 |
+
result = f"Error fetching APOD: {str(e)}"
|
48 |
+
|
49 |
+
return result
|
50 |
+
|
51 |
+
|
52 |
@tool
|
53 |
def get_current_time_in_timezone(timezone: str) -> str:
|
54 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
83 |
|
84 |
agent = CodeAgent(
|
85 |
model=model,
|
86 |
+
tools=[final_answer, get_nasa_info, duckduckgo_search_tool, get_current_time_in_timezone, image_generation_tool], ## add your tools here (don't remove final answer)
|
87 |
max_steps=6,
|
88 |
verbosity_level=1,
|
89 |
grammar=None,
|