Update app.py
Browse filesAdded all tools to the agent's tool list, and also added a joke-telling tool, changed the image generation tool
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
|
13 |
-
|
14 |
-
|
15 |
-
Args:
|
16 |
-
arg1: the first argument
|
17 |
-
arg2: the second argument
|
18 |
"""
|
19 |
-
return
|
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 =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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=[
|
|
|
|
|
|
|
|
|
|
|
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,
|