Files
DeepTutor/deeptutor/tools/web_search.py
Bingxi Zhao (Frank) f4f2a73b2a feat(search): rebuild the search provider layer and add six providers
Two pieces of work land together because the second is built on the
first: the provider layer was consolidated onto one spec table, then six
new providers were registered against it.

Layer overhaul
- Converge seven separate provider lists (backend registry, runtime
  config, settings router, CLI wizard, frontend catalog, i18n, tests)
  onto a single SEARCH_PROVIDERS spec table; every consumer derives from
  it instead of keeping its own copy.
- Fix three silent defects: serper's `num` never reached the API (it was
  swallowed by **kwargs, so max_results did nothing), serper dropped its
  proxies, and jina had no result-count limit at all.
- A runtime failure (rate limit, timeout, unreachable network) no longer
  fails the whole turn. The request walks the user's other credentialed
  search profiles and finally DuckDuckGo, recording the downgrade under
  a top-level `search_fallback` key so the trace shows what happened.
- Drop three provider modules that were never registered (exa, baidu,
  openrouter). They stay in the deprecated list, so a stale config reads
  as outdated rather than as a misspelled name.

Six new providers
doubao, bocha, zhipu, firecrawl, qianfan, aliyun_iqs — selectable under
Settings > Catalog > Search with their credential fields derived from the
spec table, and offered by `deeptutor init`. All six set
`soft_fallback=False`: five are China-hosted and the DuckDuckGo fallback
is unreachable on those networks, so a missing API key has to fail
loudly instead of silently timing out somewhere else.

Baidu returns as `qianfan` on the official Qianfan API; the old `baidu`
key stays deprecated.
2026-08-13 16:41:39 +08:00

66 lines
1.5 KiB
Python

"""
Web Search Tool - Simple entry point for agents
This module provides a simple interface to the web search service.
All search logic is implemented in deeptutor/services/search/.
Usage:
from deeptutor.tools.web_search import web_search
# Simple usage
result = web_search("What is AI?")
# With provider
result = web_search("What is AI?", provider="tavily")
Configuration:
Search profiles live in data/user/settings/model_catalog.json.
Available Providers:
Defined once in ``SEARCH_PROVIDERS``
(``deeptutor/services/config/provider_runtime.py``); call
``get_providers_info()`` for the live list with its credential requirements.
"""
# Re-export from services layer
from deeptutor.services.search import (
PROVIDER_TEMPLATES,
SEARCH_API_KEY_ENV,
AnswerConsolidator,
BaseSearchProvider,
Citation,
SearchProvider,
SearchResult,
WebSearchResponse,
get_available_providers,
get_current_config,
get_default_provider,
get_provider,
get_providers_info,
list_providers,
web_search,
)
__all__ = [
# Main function
"web_search",
"get_current_config",
# Provider management
"get_provider",
"list_providers",
"get_available_providers",
"get_default_provider",
"get_providers_info",
# Types
"WebSearchResponse",
"Citation",
"SearchResult",
# Consolidation
"AnswerConsolidator",
"PROVIDER_TEMPLATES",
# Base class
"BaseSearchProvider",
"SearchProvider",
"SEARCH_API_KEY_ENV",
]