Spaces:
Sleeping
Sleeping
Update tools/web_search.py
Browse files- tools/web_search.py +4 -2
tools/web_search.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
from typing import Any
|
| 2 |
from smolagents.tools import Tool
|
| 3 |
from ddgs import DDGS
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
class DuckDuckGoSearchTool(Tool):
|
| 7 |
name = "web_search"
|
| 8 |
-
description = "Performs a DuckDuckGo web search based on your query and returns
|
| 9 |
inputs: dict[str, dict[str, Any]] = {
|
| 10 |
"query": {"type": "string", "description": "The search query to perform."}
|
| 11 |
}
|
|
@@ -50,4 +52,4 @@ class DuckDuckGoSearchTool(Tool):
|
|
| 50 |
if not results:
|
| 51 |
raise RuntimeError("Results were returned but none contained valid URLs.")
|
| 52 |
|
| 53 |
-
return results
|
|
|
|
| 1 |
from typing import Any
|
| 2 |
from smolagents.tools import Tool
|
| 3 |
from ddgs import DDGS
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
|
| 7 |
|
| 8 |
class DuckDuckGoSearchTool(Tool):
|
| 9 |
name = "web_search"
|
| 10 |
+
description = "Performs a DuckDuckGo web search based on your query and returns an array of {title, url, snippet}"
|
| 11 |
inputs: dict[str, dict[str, Any]] = {
|
| 12 |
"query": {"type": "string", "description": "The search query to perform."}
|
| 13 |
}
|
|
|
|
| 52 |
if not results:
|
| 53 |
raise RuntimeError("Results were returned but none contained valid URLs.")
|
| 54 |
|
| 55 |
+
return json.dumps(results)
|