TheDawoud commited on
Commit
2dbad6b
·
1 Parent(s): 7e9c5fe

- Trying to get random animal photo using get animal image function

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -4,19 +4,23 @@ 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
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:
@@ -57,7 +61,7 @@ with open("prompts.yaml", 'r') as stream:
57
 
58
  agent = CodeAgent(
59
  model=model,
60
- tools=[final_answer, web_search], ## add your tools here (don't remove final answer)
61
  max_steps=6,
62
  verbosity_level=1,
63
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import base64
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 get_animal_image(animal_name:str)-> 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 gets a random animal image from the internet and returns it as base64 string
15
  Args:
16
+ arg1: the animal name
 
17
  """
18
+ #get the image from the internet
19
+ image_url = f"https://www.google.com/search?q={animal_name}&tbm=isch"
20
+ #download the image
21
+ response = requests.get(image_url)
22
+ #return the image as base64 string
23
+ return base64.b64encode(response.content).decode("utf-8")
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
 
61
 
62
  agent = CodeAgent(
63
  model=model,
64
+ tools=[final_answer, web_search, get_animal_image, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
65
  max_steps=6,
66
  verbosity_level=1,
67
  grammar=None,