Spaces:
Runtime error
Runtime error
Update app.py
Browse filesChanged to DucKDuckgo search
app.py
CHANGED
|
@@ -10,14 +10,17 @@ from Gradio_UI import GradioUI
|
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
-
def
|
| 14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 15 |
-
"""
|
| 16 |
Args:
|
| 17 |
-
|
| 18 |
-
|
| 19 |
"""
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -56,7 +59,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 56 |
|
| 57 |
agent = CodeAgent(
|
| 58 |
model=model,
|
| 59 |
-
tools=[final_answer,
|
| 60 |
max_steps=6,
|
| 61 |
verbosity_level=1,
|
| 62 |
grammar=None,
|
|
|
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def search_duckduckgo(query:str, num_results:int = 3)-> 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 |
+
"""Search DuckDuckGo and return the top results
|
| 16 |
Args:
|
| 17 |
+
query: The search term to look up
|
| 18 |
+
num_results: Number of search results to return (default is 3)
|
| 19 |
"""
|
| 20 |
+
# Format results into a readable string
|
| 21 |
+
formatted_results = "\n".join([f"{i+1}. {res['title']} - {res['url']}" for i, res in enumerate(results)])
|
| 22 |
+
|
| 23 |
+
return f"Top {num_results} search results for '{query}':\n{formatted_results}"
|
| 24 |
|
| 25 |
@tool
|
| 26 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 59 |
|
| 60 |
agent = CodeAgent(
|
| 61 |
model=model,
|
| 62 |
+
tools=[final_answer, search_duckduckgo], ## add your tools here (don't remove final answer)
|
| 63 |
max_steps=6,
|
| 64 |
verbosity_level=1,
|
| 65 |
grammar=None,
|