Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,26 +44,32 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 44 |
|
| 45 |
@tool
|
| 46 |
def web_search(query: str) -> str:
|
| 47 |
-
"""Searches the internet
|
| 48 |
-
|
|
|
|
| 49 |
Args:
|
| 50 |
query: The search terms to look up.
|
| 51 |
"""
|
| 52 |
-
try:
|
| 53 |
-
results = DDGS().text(query, max_results=5)
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
return f"Search failed: {e}. Do not retry."
|
| 66 |
|
|
|
|
| 67 |
|
| 68 |
final_answer = FinalAnswerTool()
|
| 69 |
|
|
|
|
| 44 |
|
| 45 |
@tool
|
| 46 |
def web_search(query: str) -> str:
|
| 47 |
+
"""Searches the internet using keywords.
|
| 48 |
+
Returns relevant results with URLs.
|
| 49 |
+
Do not use this tool to open a specific webpage.
|
| 50 |
Args:
|
| 51 |
query: The search terms to look up.
|
| 52 |
"""
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
for engine in ["brave", "duckduckgo", "yahoo", "mojeek"]:
|
| 55 |
+
try:
|
| 56 |
+
print(f"Searching {engine}: {query}")
|
| 57 |
|
| 58 |
+
results = DDGS().text(
|
| 59 |
+
query,
|
| 60 |
+
max_results=5,
|
| 61 |
+
backend=engine
|
| 62 |
+
)
|
| 63 |
|
| 64 |
+
if results:
|
| 65 |
+
print(f"SUCCESS: {engine}")
|
| 66 |
+
print(results)
|
| 67 |
+
return str(results)
|
| 68 |
|
| 69 |
+
except Exception as e:
|
| 70 |
+
print(f"FAILED: {engine}: {e}")
|
|
|
|
| 71 |
|
| 72 |
+
return "All search engines failed. Search unavailable."
|
| 73 |
|
| 74 |
final_answer = FinalAnswerTool()
|
| 75 |
|