Spaces:
Sleeping
Sleeping
Create tools/search_tool.py
Browse files- tools/search_tool.py +7 -0
tools/search_tool.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ddgs import DDGS
|
2 |
+
|
3 |
+
def search_duckduckgo(query: str) -> str:
|
4 |
+
with DDGS() as ddgs:
|
5 |
+
results = ddgs.text(query)
|
6 |
+
snippets = [r["body"] for r in results if "body" in r]
|
7 |
+
return " ".join(snippets[:3]) if snippets else "No result found."
|