Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -13,14 +14,31 @@ login(token = os.getenv('simpleAgentCourseToken'))
|
|
| 13 |
|
| 14 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 15 |
@tool
|
| 16 |
-
def
|
| 17 |
-
|
| 18 |
-
"""A tool that
|
| 19 |
Args:
|
| 20 |
-
|
| 21 |
-
arg2: the second argument
|
| 22 |
"""
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
@tool
|
| 26 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import json
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
|
|
| 14 |
|
| 15 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 16 |
@tool
|
| 17 |
+
def get_movie_info(title:str)-> str: #it's import to specify the return type
|
| 18 |
+
|
| 19 |
+
"""A tool that retrieves comprehensive information about a movie.
|
| 20 |
Args:
|
| 21 |
+
title: A string representing a movie title (e.g., 'Parasite')
|
|
|
|
| 22 |
"""
|
| 23 |
+
login(movieOmdbKey = os.getenv('movieOmdbKey'))
|
| 24 |
+
if not movieOmdbKey:
|
| 25 |
+
print("Error: movieOmdbKey environment variable not set.")
|
| 26 |
+
return None
|
| 27 |
+
|
| 28 |
+
# Build API URL
|
| 29 |
+
api_url = f"http://www.omdbapi.com/?apikey={movieOmdbKey}&t={movie_title}"
|
| 30 |
+
|
| 31 |
+
# Make API request
|
| 32 |
+
response = requests.get(api_url)
|
| 33 |
+
|
| 34 |
+
# Handle response
|
| 35 |
+
if response.status_code == 200:
|
| 36 |
+
data = response.json()
|
| 37 |
+
string_data = json.dumps(data)
|
| 38 |
+
return string_data
|
| 39 |
+
else:
|
| 40 |
+
print(f"Error: Unable to fetch movie data for '{movie_title}'. Status code: {response.status_code}")
|
| 41 |
+
return None
|
| 42 |
|
| 43 |
@tool
|
| 44 |
def get_current_time_in_timezone(timezone: str) -> str:
|