piyushdev commited on
Commit
c21707c
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files

Added all tools to the agent's tool list, and also added a joke-telling tool, changed the image generation tool

Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -4,19 +4,18 @@ 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:
@@ -48,14 +47,26 @@ custom_role_conversions=None,
48
 
49
 
50
  # Import tool from Hub
51
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
 
 
 
 
 
 
 
52
 
53
  with open("prompts.yaml", 'r') as stream:
54
  prompt_templates = yaml.safe_load(stream)
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
 
 
 
 
 
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import os
8
+ import pyjokes
9
 
10
  from Gradio_UI import GradioUI
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
+ def tell_a_joke() -> str:
15
+ """
16
+ Tells a random programmer joke.
 
 
 
17
  """
18
+ return pyjokes.get_joke()
19
 
20
  @tool
21
  def get_current_time_in_timezone(timezone: str) -> str:
 
47
 
48
 
49
  # Import tool from Hub
50
+ image_generation_tool = Tool.from_space(
51
+ "black-forest-labs/FLUX.1-schnell",
52
+ name="image_generator",
53
+ description="Generate an image from a prompt"
54
+ )
55
+
56
+ # Web search tool
57
+ search_tool=DuckDuckGoSearchTool()
58
 
59
  with open("prompts.yaml", 'r') as stream:
60
  prompt_templates = yaml.safe_load(stream)
61
 
62
  agent = CodeAgent(
63
  model=model,
64
+ tools=[
65
+ final_answer,
66
+ get_current_time_in_timezone,
67
+ image_generation_tool,
68
+ search_tool,
69
+ tell_a_joke], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,