Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,25 @@ from tools.final_answer import FinalAnswerTool
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
+
search_tool = DuckDuckGoSearchTool()
|
11 |
+
|
12 |
+
@tool
|
13 |
+
def web_search(query: str) -> str:
|
14 |
+
"""
|
15 |
+
Performs a web search using DuckDuckGo and returns the top result.
|
16 |
+
|
17 |
+
Args:
|
18 |
+
query: The search query string.
|
19 |
+
|
20 |
+
Returns:
|
21 |
+
The title and URL of the top search result.
|
22 |
+
"""
|
23 |
+
results = search_tool(query)
|
24 |
+
if results:
|
25 |
+
top_result = results[0]
|
26 |
+
return f"Title: {top_result['title']}\nURL: {top_result['url']}"
|
27 |
+
else:
|
28 |
+
return "No results found."
|
29 |
|
30 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
31 |
@tool
|