diff options
Diffstat (limited to 'src/ollama_web/tools')
| -rw-r--r-- | src/ollama_web/tools/search.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ollama_web/tools/search.py b/src/ollama_web/tools/search.py index 761f182..773f7f3 100644 --- a/src/ollama_web/tools/search.py +++ b/src/ollama_web/tools/search.py @@ -2,10 +2,14 @@ from __future__ import annotations +import logging + from ddgs import DDGS from ..config import settings +logger = logging.getLogger(__name__) + def web_search(query: str, max_results: int | None = None) -> list[dict[str, str]]: """Search the web using DuckDuckGo and return compact result summaries. @@ -16,7 +20,8 @@ def web_search(query: str, max_results: int | None = None) -> list[dict[str, str Returns: A list of dictionaries with keys 'title', 'href' and 'body' for each - result. Returns an empty list if the search fails or no results are found. + result. Returns an empty list if no results are found. Provider failures + are logged and propagated to the tool execution layer. """ if not query or not query.strip(): return [] @@ -37,7 +42,9 @@ def web_search(query: str, max_results: int | None = None) -> list[dict[str, str } ) except Exception: # noqa: BLE001 - # Swallow network/runtime errors so the chat loop can continue. - return [] + # Preserve the provider exception for the tool layer while recording + # the traceback without logging the potentially sensitive query. + logger.exception("DuckDuckGo web search failed") + raise return results[:limit] |
