Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,17 +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 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""A tool that does
|
15 |
Args:
|
16 |
-
|
17 |
-
arg2: the second argument
|
18 |
"""
|
19 |
# return "What magic will you build ?"
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
@tool
|
23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
+
duckduckgo_tool=DuckDuckGoSearchTool()
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
13 |
+
def animewatcher(anime_name:str)-> str: #it's import to specify the return type
|
14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
15 |
+
"""A tool that does search the details abt a given anime using duckduckgo
|
16 |
Args:
|
17 |
+
anime_name: The name of the anime to search for.
|
|
|
18 |
"""
|
19 |
# return "What magic will you build ?"
|
20 |
+
try:
|
21 |
+
search_query=f"{anime_name} anime details "
|
22 |
+
result=duckduckgo_tool(search_query,max_results=3)#get the top 3 search results.
|
23 |
+
if not results:
|
24 |
+
return "No results found for the given anime. Maybe! it's underrrated!"
|
25 |
+
response = f"Here are some info of '{anime_name}':\n"
|
26 |
+
for i , result in enumerate (results,1):
|
27 |
+
response+=f"{i} . **{result['title']}**\n{result['href']}\n\n"
|
28 |
+
return response.strip()
|
29 |
+
except Exception as e:
|
30 |
+
return f"Error searching for '{anime_name}':{str(e)}"
|
31 |
|
32 |
@tool
|
33 |
def get_current_time_in_timezone(timezone: str) -> str:
|