Update app.py
Browse filesAdded a few tools to the agent.
app.py
CHANGED
|
@@ -9,14 +9,42 @@ 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 |
-
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +83,7 @@ with open("prompts.yaml", 'r') as 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,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def generate_funny_poem(theme: str, lines: int) -> str:
|
| 13 |
+
"""A tool that generates a short, humorous poem based on a theme.
|
|
|
|
| 14 |
Args:
|
| 15 |
+
theme: The theme of the poem (e.g., 'cats', 'space', 'love').
|
| 16 |
+
lines: The number of lines in the poem (between 2 and 6).
|
| 17 |
"""
|
| 18 |
+
funny_lines = {
|
| 19 |
+
"cats": [
|
| 20 |
+
"The cat just stole my dinner plate,",
|
| 21 |
+
"It looked at me, then licked its fate.",
|
| 22 |
+
"Nine lives, but none for rent,",
|
| 23 |
+
"Sleeps all day, pays no rent!"
|
| 24 |
+
],
|
| 25 |
+
"space": [
|
| 26 |
+
"A rocket zoomed across the night,",
|
| 27 |
+
"Aliens waved, quite polite!",
|
| 28 |
+
"I asked them for a cup of tea,",
|
| 29 |
+
"They said, 'No thanks, we drink gravity!'"
|
| 30 |
+
],
|
| 31 |
+
"love": [
|
| 32 |
+
"Roses are red, violets are blue,",
|
| 33 |
+
"I bought you coffee, now marry me too!",
|
| 34 |
+
"You stole my heart, just like my fries,",
|
| 35 |
+
"But I forgive you—those puppy eyes!"
|
| 36 |
+
],
|
| 37 |
+
"default": [
|
| 38 |
+
"Life’s a joke, and so am I,",
|
| 39 |
+
"Still, I try and still I sigh.",
|
| 40 |
+
"If laughter’s gold, then I'm quite broke,",
|
| 41 |
+
"Guess I'll survive on just my jokes!"
|
| 42 |
+
]
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
selected_lines = funny_lines.get(theme, funny_lines["default"])
|
| 46 |
+
poem = "\n".join(random.sample(selected_lines, min(lines, len(selected_lines))))
|
| 47 |
+
return f"Here's a fun little poem about {theme}:\n\n{poem}"
|
| 48 |
|
| 49 |
@tool
|
| 50 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 83 |
|
| 84 |
agent = CodeAgent(
|
| 85 |
model=model,
|
| 86 |
+
tools=[final_answer, generate_funny_poem, image_generation_tool, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 87 |
max_steps=6,
|
| 88 |
verbosity_level=1,
|
| 89 |
grammar=None,
|