Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,9 +8,6 @@ from tools.final_answer import FinalAnswerTool
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
|
| 11 |
-
from duckduckgo_search import DDGS
|
| 12 |
-
from langchain.tools import tool
|
| 13 |
-
|
| 14 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 15 |
@tool
|
| 16 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -38,24 +35,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 38 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 39 |
|
| 40 |
|
| 41 |
-
|
| 42 |
-
def duckduckgo_search(query: str, max_results: int = 5) -> str:
|
| 43 |
-
"""Search DuckDuckGo and return concise results.
|
| 44 |
-
Args:
|
| 45 |
-
query: The search query string
|
| 46 |
-
max_results: Maximum number of results to return
|
| 47 |
-
"""
|
| 48 |
-
results = []
|
| 49 |
-
with DDGS() as ddgs:
|
| 50 |
-
for r in ddgs.text(query, max_results=max_results):
|
| 51 |
-
results.append(
|
| 52 |
-
f"- {r.get('title')}:\n {r.get('body')}\n Source: {r.get('href')}"
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
if not results:
|
| 56 |
-
return "No results found."
|
| 57 |
-
|
| 58 |
-
return "\n\n".join(results)
|
| 59 |
|
| 60 |
final_answer = FinalAnswerTool()
|
| 61 |
|
|
@@ -78,7 +58,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 78 |
|
| 79 |
agent = CodeAgent(
|
| 80 |
model=model,
|
| 81 |
-
tools=[final_answer,
|
| 82 |
max_steps=6,
|
| 83 |
verbosity_level=1,
|
| 84 |
grammar=None,
|
|
|
|
| 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
|
| 13 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 35 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 36 |
|
| 37 |
|
| 38 |
+
duckduckgo_tool = DuckDuckGoSearchTool()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
final_answer = FinalAnswerTool()
|
| 41 |
|
|
|
|
| 58 |
|
| 59 |
agent = CodeAgent(
|
| 60 |
model=model,
|
| 61 |
+
tools=[final_answer,duckduckgo_tool, my_custom_tool], ## add your tools here (don't remove final answer)
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|