Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,28 @@
|
|
| 1 |
from smolagents import CodeAgent,HfApiModel,load_tool,tool
|
| 2 |
-
|
| 3 |
import datetime
|
| 4 |
import requests
|
| 5 |
import pytz
|
| 6 |
import yaml
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
from tools.visit_webpage import VisitWebpageTool
|
| 9 |
-
from tools.web_search import DuckDuckGoSearchTool
|
| 10 |
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
# """A tool that runs a DuckDuckGo search and returns a formatted result.
|
| 18 |
# Args:
|
| 19 |
# query: A string representing the query to search for.
|
| 20 |
# """
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
@tool
|
| 28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -41,7 +41,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 41 |
|
| 42 |
|
| 43 |
final_answer = FinalAnswerTool()
|
| 44 |
-
web_search = DuckDuckGoSearchTool()
|
| 45 |
visit_webpage = VisitWebpageTool()
|
| 46 |
|
| 47 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 1 |
from smolagents import CodeAgent,HfApiModel,load_tool,tool
|
| 2 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool,HfApiModel,load_tool,tool
|
| 3 |
import datetime
|
| 4 |
import requests
|
| 5 |
import pytz
|
| 6 |
import yaml
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
from tools.visit_webpage import VisitWebpageTool
|
| 9 |
+
# from tools.web_search import DuckDuckGoSearchTool
|
| 10 |
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
| 13 |
+
ddg = DuckDuckGoSearchTool(max_results=5)
|
| 14 |
|
| 15 |
+
@tool
|
| 16 |
+
def web_search(query:str)-> str:
|
| 17 |
# """A tool that runs a DuckDuckGo search and returns a formatted result.
|
| 18 |
# Args:
|
| 19 |
# query: A string representing the query to search for.
|
| 20 |
# """
|
| 21 |
+
try:
|
| 22 |
+
results = ddg(query)
|
| 23 |
+
return results
|
| 24 |
+
except Exception as e:
|
| 25 |
+
return f"Error while searching: {str(e)}"
|
| 26 |
|
| 27 |
@tool
|
| 28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
final_answer = FinalAnswerTool()
|
| 44 |
+
# web_search = DuckDuckGoSearchTool()
|
| 45 |
visit_webpage = VisitWebpageTool()
|
| 46 |
|
| 47 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|