Spaces:
Sleeping
Sleeping
Commit
·
3c6fa1c
1
Parent(s):
ae7a494
Add random quote tool
Browse files
app.py
CHANGED
|
@@ -7,16 +7,27 @@ 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 |
-
|
| 16 |
-
arg1: the first argument
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
| 10 |
@tool
|
| 11 |
+
def get_random_quote() -> str:
|
| 12 |
+
"""Fetches a random quote from the Quotable API.
|
| 13 |
+
Returns:
|
| 14 |
+
A string containing a random quote.
|
|
|
|
|
|
|
| 15 |
"""
|
| 16 |
+
try:
|
| 17 |
+
# Make a request to the quote API
|
| 18 |
+
response = requests.get("https://api.quotable.io/random", verify=False)
|
| 19 |
+
data = response.json()
|
| 20 |
+
|
| 21 |
+
if response.status_code == 200:
|
| 22 |
+
# Extract quote information
|
| 23 |
+
content = data['content']
|
| 24 |
+
author = data['author']
|
| 25 |
+
return f'"{content}" - {author}'
|
| 26 |
+
else:
|
| 27 |
+
return "Error fetching quote: Unknown error"
|
| 28 |
+
except Exception as e:
|
| 29 |
+
return f"Error fetching quote: {str(e)}"
|
| 30 |
+
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 66 |
|
| 67 |
agent = CodeAgent(
|
| 68 |
model=model,
|
| 69 |
+
tools=[final_answer, DuckDuckGoSearchTool(), image_generation_tool, get_random_quote, get_current_time_in_timezone],
|
| 70 |
max_steps=6,
|
| 71 |
verbosity_level=1,
|
| 72 |
grammar=None,
|