khiem-dangle commited on
Commit
0d6393f
·
verified ·
1 Parent(s): bdf15fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -6
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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
17
- #Keep this format for the description / args / args description but feel free to modify the tool
18
- """A tool that does nothing yet
19
  Args:
20
- arg1: the first argument
21
- arg2: the second argument
22
  """
23
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: