Spaces:
Sleeping
Sleeping
added DuckDuckGoSearchTool
Browse files
app.py
CHANGED
|
@@ -7,26 +7,6 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
@tool
|
| 11 |
-
def duckduckgo_search(query: str, max_results: int = 5) -> str:
|
| 12 |
-
"""A tool that searches the web using DuckDuckGo.
|
| 13 |
-
Args:
|
| 14 |
-
query: The search query string.
|
| 15 |
-
max_results: The number of search results to return (default: 5).
|
| 16 |
-
"""
|
| 17 |
-
try:
|
| 18 |
-
search_tool = DuckDuckGoSearchTool()
|
| 19 |
-
results = search_tool.search(query=query, num_results=max_results)
|
| 20 |
-
|
| 21 |
-
if results:
|
| 22 |
-
formatted_results = "\n".join(
|
| 23 |
-
[f"{i+1}. {res['title']} ({res['href']})" for i, res in enumerate(results)]
|
| 24 |
-
)
|
| 25 |
-
return f"Top {max_results} results for '{query}':\n{formatted_results}"
|
| 26 |
-
else:
|
| 27 |
-
return f"No results found for '{query}'."
|
| 28 |
-
except Exception as e:
|
| 29 |
-
return f"Error performing search: {str(e)}"
|
| 30 |
|
| 31 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 32 |
@tool
|
|
@@ -77,7 +57,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 77 |
|
| 78 |
agent = CodeAgent(
|
| 79 |
model=model,
|
| 80 |
-
tools=[
|
| 81 |
max_steps=6,
|
| 82 |
verbosity_level=1,
|
| 83 |
grammar=None,
|
|
|
|
| 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
|
|
|
|
| 57 |
|
| 58 |
agent = CodeAgent(
|
| 59 |
model=model,
|
| 60 |
+
tools=[DuckDuckGoSearchTool, get_current_time_in_timezone, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
|
| 61 |
max_steps=6,
|
| 62 |
verbosity_level=1,
|
| 63 |
grammar=None,
|