Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,29 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@tool
|
| 23 |
def get_random_cocktail() -> str:
|
| 24 |
"""A tool that fetches a random cocktail recipe.
|
|
@@ -75,7 +98,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 75 |
|
| 76 |
agent = CodeAgent(
|
| 77 |
model=model,
|
| 78 |
-
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, get_random_cocktail], ## add your tools here (don't remove final answer)
|
| 79 |
max_steps=6,
|
| 80 |
verbosity_level=1,
|
| 81 |
grammar=None,
|
|
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
|
| 22 |
+
@tool
|
| 23 |
+
def search_dad_jokes(term: str) -> str:
|
| 24 |
+
"""A tool that searches for dad jokes containing a specific term.
|
| 25 |
+
Args:
|
| 26 |
+
term: The keyword to search for in dad jokes.
|
| 27 |
+
"""
|
| 28 |
+
try:
|
| 29 |
+
headers = {
|
| 30 |
+
"Accept": "application/json",
|
| 31 |
+
"User-Agent": "YourAppName (https://yourappurl.com)"
|
| 32 |
+
}
|
| 33 |
+
response = requests.get(f"https://icanhazdadjoke.com/search?term={term}", headers=headers)
|
| 34 |
+
data = response.json()
|
| 35 |
+
if data['results']:
|
| 36 |
+
jokes = [joke['joke'] for joke in data['results']]
|
| 37 |
+
return f"Found {len(jokes)} jokes:\n" + "\n\n".join(jokes)
|
| 38 |
+
else:
|
| 39 |
+
return f"No jokes found for the term '{term}'."
|
| 40 |
+
except Exception as e:
|
| 41 |
+
return f"Error searching for jokes: {str(e)}"
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
@tool
|
| 46 |
def get_random_cocktail() -> str:
|
| 47 |
"""A tool that fetches a random cocktail recipe.
|
|
|
|
| 98 |
|
| 99 |
agent = CodeAgent(
|
| 100 |
model=model,
|
| 101 |
+
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, get_random_cocktail, search_dad_jokes], ## add your tools here (don't remove final answer)
|
| 102 |
max_steps=6,
|
| 103 |
verbosity_level=1,
|
| 104 |
grammar=None,
|