Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool,
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -32,15 +32,15 @@ def web_search_DDG(query:str)-> str:
|
|
| 32 |
if not results or "No results found" in results:
|
| 33 |
return f"No answer was found to the request '{query}'. Please reformulate."
|
| 34 |
return f"The answer for the question '{query}' is:\n\n{results}"
|
| 35 |
-
except Exception as
|
| 36 |
try:
|
| 37 |
-
search_tool =
|
| 38 |
results = search_tool(query)
|
| 39 |
if not results or "No results found" in results:
|
| 40 |
return f"No answer was found to the request '{query}'. Please reformulate."
|
| 41 |
return f"The answer for the question '{query}' is:\n\n{results}"
|
| 42 |
-
except Exception as
|
| 43 |
-
return f"An unexpected issue occurred: {str(
|
| 44 |
|
| 45 |
|
| 46 |
@tool
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool, GoogleSearchTool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 32 |
if not results or "No results found" in results:
|
| 33 |
return f"No answer was found to the request '{query}'. Please reformulate."
|
| 34 |
return f"The answer for the question '{query}' is:\n\n{results}"
|
| 35 |
+
except Exception as e1:
|
| 36 |
try:
|
| 37 |
+
search_tool = GoogleSearchTool(engine="bing")
|
| 38 |
results = search_tool(query)
|
| 39 |
if not results or "No results found" in results:
|
| 40 |
return f"No answer was found to the request '{query}'. Please reformulate."
|
| 41 |
return f"The answer for the question '{query}' is:\n\n{results}"
|
| 42 |
+
except Exception as e2:
|
| 43 |
+
return f"An unexpected issue occurred: {str(e1) + ' ' + str(e2)}"
|
| 44 |
|
| 45 |
|
| 46 |
@tool
|