Spaces:
Sleeping
Sleeping
Added new tools
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
@@ -9,14 +9,33 @@ 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 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +74,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,
|
|
|
1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def prophetic_oracle(word: str, lucky_number: int) -> str: #it's import to specify the return type
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
+
"""Reveals a mystical prophecy and fetches a real-time search result.
|
15 |
Args:
|
16 |
+
word: A keyword that unlocks fate.
|
17 |
+
lucky_number: A number that tilts destiny.
|
18 |
+
Returns:
|
19 |
+
A fortune and a live web search link.
|
20 |
"""
|
21 |
+
|
22 |
+
messages = [
|
23 |
+
"The universe conspires in your favor.",
|
24 |
+
"A secret truth will soon unfold.",
|
25 |
+
"Beware of doors that open too easily.",
|
26 |
+
"Your energy attracts hidden opportunities.",
|
27 |
+
"A path once lost will be found again.",
|
28 |
+
"In the unseen, answers await."
|
29 |
+
]
|
30 |
+
|
31 |
+
seed = sum(ord(c) for c in word) + lucky_number
|
32 |
+
fortune = messages[seed % len(messages)]
|
33 |
+
|
34 |
+
# Perform a real-time web search
|
35 |
+
search_tool = DuckDuckGoSearchTool()
|
36 |
+
search_result = search_tool.search(word)
|
37 |
+
|
38 |
+
return f"🔮 Fortune Code {seed}: {fortune}\n🌐 Relevant insight: {search_result}"
|
39 |
|
40 |
@tool
|
41 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
74 |
|
75 |
agent = CodeAgent(
|
76 |
model=model,
|
77 |
+
tools=[final_answer, get_current_time_in_timezone, prophetic_oracle], ## add your tools here (don't remove final answer)
|
78 |
max_steps=6,
|
79 |
verbosity_level=1,
|
80 |
grammar=None,
|