vadhri commited on
Commit
19cc399
·
verified ·
1 Parent(s): 9af5af3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -4,19 +4,39 @@ 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_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
  """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -51,7 +71,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import json
8
 
9
  from Gradio_UI import GradioUI
10
 
11
+ movies = {}
12
+ with open('movies.json') as f:
13
+ movies = json.load(f)
14
+
15
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
16
  @tool
17
+ def movie_info(arg1:movie_name)-> str: #it's import to specify the return type
18
  #Keep this format for the description / args / args description but feel free to modify the tool
19
  """A tool that does nothing yet
20
  Args:
21
+ arg1: name of the movie
 
22
  """
23
+
24
+ try:
25
+ # read and create an object of information about a movie requested.
26
+ filtered_movies = [movie for movie in movies if movie["Title"].lower() == movie_name.lower()]
27
+ if len(filtered_movies) > 0:
28
+ output = ""
29
+ for movie in filtered_movies:
30
+ output += movie['Title'] + ","
31
+ output += movie['Year'] + ","
32
+ output += movie['imdbRating'] + ","
33
+ output += movie['imdbVotes'] + ","
34
+ output += movie['Actors'] + ","
35
+
36
+ output += "\n"
37
+ else:
38
+ output = "No information on that movie found!"
39
+ return output
40
 
41
  @tool
42
  def get_current_time_in_timezone(timezone: str) -> str:
 
71
 
72
  agent = CodeAgent(
73
  model=model,
74
+ tools=[final_answer, ], ## add your tools here (don't remove final answer)
75
  max_steps=6,
76
  verbosity_level=1,
77
  grammar=None,