Spaces:
Sleeping
Sleeping
Delete tools/search_tool.py
Browse files- tools/search_tool.py +0 -22
tools/search_tool.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
from duckduckgo_search import DDGS
|
| 2 |
-
import time
|
| 3 |
-
|
| 4 |
-
def search_duckduckgo(query: str, max_results: int = 5) -> str:
|
| 5 |
-
"""Sök på DuckDuckGo och returnera sammanfattning"""
|
| 6 |
-
try:
|
| 7 |
-
summary = []
|
| 8 |
-
|
| 9 |
-
with DDGS() as ddgs:
|
| 10 |
-
results = ddgs.text(query, max_results=max_results)
|
| 11 |
-
|
| 12 |
-
for i, result in enumerate(results, 1):
|
| 13 |
-
summary.append(f"Result {i}:")
|
| 14 |
-
summary.append(f"Title: {result['title']}")
|
| 15 |
-
summary.append(f"URL: {result['href']}")
|
| 16 |
-
summary.append(f"Content: {result['body']}")
|
| 17 |
-
summary.append("-" * 50)
|
| 18 |
-
|
| 19 |
-
return "\n".join(summary) if summary else "No relevant results found."
|
| 20 |
-
|
| 21 |
-
except Exception as e:
|
| 22 |
-
return f"Error searching: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|