Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,19 +4,31 @@ 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 |
-
"""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:
|
@@ -51,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
51 |
|
52 |
agent = CodeAgent(
|
53 |
model=model,
|
54 |
-
|
55 |
max_steps=6,
|
56 |
verbosity_level=1,
|
57 |
grammar=None,
|
|
|
4 |
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
+
from typing import Tuple
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
+
|
13 |
@tool
|
14 |
+
def get_anime_quotes() -> Tuple[str, str, str]:
|
15 |
+
"""A tool that fetches a random anime quote.
|
|
|
16 |
Args:
|
17 |
+
None
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
A tuple containing the quote content, anime name, and character name.
|
21 |
"""
|
22 |
+
response = requests.get("https://animechan.io/api/v1/quotes/random")
|
23 |
+
if response.status_code == 200:
|
24 |
+
data = response.json()
|
25 |
+
if data["status"] == "success":
|
26 |
+
quote = data["data"]["content"]
|
27 |
+
anime = data["data"]["anime"]["name"]
|
28 |
+
character = data["data"]["character"]["name"]
|
29 |
+
return quote, anime, character
|
30 |
+
return "Failed to fetch quote", "", ""
|
31 |
+
|
32 |
|
33 |
@tool
|
34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
63 |
|
64 |
agent = CodeAgent(
|
65 |
model=model,
|
66 |
+
tools=[final_answer, image_generation_tool, get_anime_quotes, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
67 |
max_steps=6,
|
68 |
verbosity_level=1,
|
69 |
grammar=None,
|