Spaces:
Sleeping
Sleeping
Stoyan Georgiev
commited on
Commit
·
7ead233
1
Parent(s):
fc2c2bb
Updated the Space with new features
Browse files
app.py
CHANGED
@@ -8,33 +8,33 @@ from tools.final_answer import FinalAnswerTool
|
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
# Get today's date string (e.g., "2025-02-11")
|
21 |
-
|
22 |
|
23 |
# Build a query that hints at today's news.
|
24 |
# Including the date in the query helps nudge the search towards recent articles.
|
25 |
-
|
26 |
|
27 |
# Initialize and run the search tool
|
28 |
-
|
29 |
-
|
30 |
|
31 |
# Optionally: filter the returned lines if they include today's date.
|
32 |
# (This assumes that the news snippets contain the publication date in "YYYY-MM-DD" format.)
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
|
39 |
@tool
|
40 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -68,13 +68,13 @@ with open("prompts.yaml", 'r') as stream:
|
|
68 |
|
69 |
agent = CodeAgent(
|
70 |
model=model,
|
71 |
-
tools=[final_answer, get_current_time_in_timezone], # Add your tool here
|
72 |
max_steps=6,
|
73 |
verbosity_level=1,
|
74 |
grammar=None,
|
75 |
planning_interval=None,
|
76 |
name="TimeZone Agent",
|
77 |
-
description="An agent that can provide the current time in any timezone and perform other tasks.",
|
78 |
prompt_templates=prompt_templates
|
79 |
)
|
80 |
|
|
|
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 my_cutom_tool(arg1: str, arg2: int) -> str:
|
13 |
+
"""A tool that uses DuckDuckGoSearchTool to fetch Bitcoin news from today.
|
14 |
+
|
15 |
+
Args:
|
16 |
+
arg1: (Unused) Reserved for future use.
|
17 |
+
arg2: (Unused) Reserved for future use.
|
18 |
+
"""
|
19 |
|
20 |
# Get today's date string (e.g., "2025-02-11")
|
21 |
+
today = datetime.now().strftime("%Y-%m-%d")
|
22 |
|
23 |
# Build a query that hints at today's news.
|
24 |
# Including the date in the query helps nudge the search towards recent articles.
|
25 |
+
query = f"Bitcoin news {today}"
|
26 |
|
27 |
# Initialize and run the search tool
|
28 |
+
search_tool = DuckDuckGoSearchTool()
|
29 |
+
results = search_tool.run(query)
|
30 |
|
31 |
# Optionally: filter the returned lines if they include today's date.
|
32 |
# (This assumes that the news snippets contain the publication date in "YYYY-MM-DD" format.)
|
33 |
+
filtered_results = "\n".join(
|
34 |
+
line for line in results.splitlines() if today in line
|
35 |
+
)
|
36 |
|
37 |
+
return filtered_results if filtered_results else "No current Bitcoin news found for today."
|
38 |
|
39 |
@tool
|
40 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
68 |
|
69 |
agent = CodeAgent(
|
70 |
model=model,
|
71 |
+
tools=[final_answer, get_current_time_in_timezone, my_cutom_tool], # Add your tool here
|
72 |
max_steps=6,
|
73 |
verbosity_level=1,
|
74 |
grammar=None,
|
75 |
planning_interval=None,
|
76 |
name="TimeZone Agent",
|
77 |
+
description="An agent that can provide the current time in any timezone, get current news and perform other tasks.",
|
78 |
prompt_templates=prompt_templates
|
79 |
)
|
80 |
|