Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,25 @@ def get_weather(city: str) -> str:
|
|
| 22 |
except Exception as e:
|
| 23 |
return f"Error: {str(e)}"
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 26 |
@tool
|
| 27 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -70,13 +89,13 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 70 |
|
| 71 |
agent = CodeAgent(
|
| 72 |
model=model,
|
| 73 |
-
tools=[final_answer,get_current_time_in_timezone, get_weather],
|
| 74 |
max_steps=6,
|
| 75 |
verbosity_level=1,
|
| 76 |
grammar=None,
|
| 77 |
planning_interval=None,
|
| 78 |
-
name=
|
| 79 |
-
description=
|
| 80 |
prompt_templates=prompt_templates
|
| 81 |
)
|
| 82 |
|
|
|
|
| 22 |
except Exception as e:
|
| 23 |
return f"Error: {str(e)}"
|
| 24 |
|
| 25 |
+
@tool
|
| 26 |
+
def generate_pun(topic: str) -> str:
|
| 27 |
+
"""Generates a spontaneous pun based on a given topic.
|
| 28 |
+
Args:
|
| 29 |
+
topic: The subject to base the pun on.
|
| 30 |
+
"""
|
| 31 |
+
try:
|
| 32 |
+
puns = {
|
| 33 |
+
"banana": "I find bananas very *a-peeling*.",
|
| 34 |
+
"fish": "You cod not be more fin-tastic!",
|
| 35 |
+
"computer": "My computer wanted to dance, so I gave it the disk-o.",
|
| 36 |
+
"coffee": "I’ve bean thinking about you!",
|
| 37 |
+
"time": "I wanted to be a watchmaker, but I just didn’t have the time.",
|
| 38 |
+
"weather": "I tried to catch some fog... but I mist.",
|
| 39 |
+
}
|
| 40 |
+
return puns.get(topic.lower(), f"I don't have a pun for '{topic}' yet, but I’ll *try* not to make a joke of it!")
|
| 41 |
+
expect Exception as e:
|
| 42 |
+
return f"OOps, couldn't generate a pun: {str(e)}"
|
| 43 |
+
|
| 44 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 45 |
@tool
|
| 46 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 89 |
|
| 90 |
agent = CodeAgent(
|
| 91 |
model=model,
|
| 92 |
+
tools=[final_answer,get_current_time_in_timezone, get_weather, generate_pun],
|
| 93 |
max_steps=6,
|
| 94 |
verbosity_level=1,
|
| 95 |
grammar=None,
|
| 96 |
planning_interval=None,
|
| 97 |
+
name="Son of Anton",
|
| 98 |
+
description="Your friendly Ai agent to help you with any task",
|
| 99 |
prompt_templates=prompt_templates
|
| 100 |
)
|
| 101 |
|