feat(tools): add DeepSeek Search as a web_search provider

Add a standalone `deepseek` search backend that calls the DeepSeek Search
API (POST https://api.deepseek.com/v1/tools/search), following the
provider layout used by AnySearch (#5607) and Bocha (#4182).

This is a search-only integration. It does not touch the DeepSeek LLM
provider, does not inject a `web_search` tool into model requests, and
does not implement the Fetch endpoint.

- Trim and truncate queries to the API's 128 Unicode-character limit
  locally, rejecting whitespace-only queries without a network call.
- Clamp `count` to the API's 1-50 range and always send
  `need_content: false` so page bodies stay out of the model context.
- Format results from `summary`, falling back to `snippet` when a summary
  is missing or blank, and include `date` when present. Cap each result's
  text at 500 characters: live responses reach ~4,500 characters, so ten
  uncapped results cost roughly 10k tokens per call.
- Return actionable 401 and 402 messages; retry 408/429/5xx once after
  1.0s like the Brave provider; surface `error.message` for other 4xx,
  tag-stripped because the upstream body is untrusted. Unexpected
  transport errors report the exception type only, with the detail
  logged when tool log content is allowed.
- Read the key from `tools.web.search.apiKey` or `DEEPSEEK_API_KEY` and
  fall back to DuckDuckGo when neither is set, like other keyed
  providers. The key is never logged or echoed in errors.
- Register the provider for the CLI wizard and WebUI settings, and reuse
  the bundled DeepSeek brand asset.
This commit is contained in:
moran authored and chengyongru committed 2026-10-19 16:50:17 +08:00
1 parent 5d886fbb20
commit e5b469ebd4
5 files changed
+759 -2

No files matched your search

+31 -1
View File
@@ -2064,11 +2064,41 @@ Create a key at [serper.dev](https://serper.dev). You can also set `SERPER_API_K
AnySearch works out of the box with no key, via its anonymous quota (lower rate limits). Set `apiKey` (or `ANYSEARCH_API_KEY`) from [anysearch.com](https://anysearch.com/console/api-keys) to lift rate limits. It also offers vertical-domain search and full-page URL content extraction.
**DeepSeek** (keyed, separate Search API):
<details>
<summary>Manual configuration</summary>
```json
{
"tools": {
"web": {
"search": {
"provider": "deepseek",
"apiKey": "${DEEPSEEK_API_KEY}"
}
}
}
}
```
</details>
This provider calls the standalone [DeepSeek Search API](https://api-docs.deepseek.com/zh-cn/guides/search/) (`POST https://api.deepseek.com/v1/tools/search`). It is a separate web-search backend and is **not** the same as the provider-hosted web search that DeepSeek models can run inside a chat request; selecting `deepseek` here does not change the DeepSeek LLM provider or inject any tool into model requests.
- Create a key at [platform.deepseek.com](https://platform.deepseek.com). The key can also come from the `DEEPSEEK_API_KEY` environment variable. Without a key, nanobot falls back to DuckDuckGo, like the other keyed search providers.
- Billing is per successful request: ¥5 per 1,000 requests. Requests that fail, time out, or return no results are not billed. `count` only changes the number of results and not the price.
- The account limit is 5 QPS. nanobot retries HTTP 408, 429, and 5xx responses once after one second before reporting the failure; other 4xx responses are not retried.
- A query is limited to 128 Unicode characters. nanobot trims surrounding whitespace and truncates longer queries locally, so no request that would fail with HTTP 400 is sent.
- Search syntax is passed through unchanged: `site:`, `-site:`, `-`, `-"..."`, `"..."`, `lang:`, `after:`, and `before:`. For example: `DeepSeek models site:github.com lang:zh after:2025`.
- Results use the API's `summary`, falling back to `snippet` when a summary is missing. Each result's text is capped at 500 characters, because real responses can be several times longer than the documented 600–800, and ten uncapped summaries would cost around 10k tokens per call. The publication date is included when the API returns one.
nanobot requests results without page bodies (`need_content: false`), so full page text is not added to the model's context. Use `web_fetch` when you need the page content.
#### `tools.web.search`
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `provider` | string | `"duckduckgo"` | Search backend: `brave`, `tavily`, `jina`, `kagi`, `olostep`, `bocha`, `volcengine`, `keenable`, `serper`, `anysearch`, `searxng`, `duckduckgo` |
| `provider` | string | `"duckduckgo"` | Search backend: `brave`, `tavily`, `jina`, `kagi`, `olostep`, `bocha`, `volcengine`, `keenable`, `serper`, `anysearch`, `deepseek`, `searxng`, `duckduckgo` |
| `apiKey` | string | `""` | API key for API-backed search providers |
| `baseUrl` | string | `""` | Base URL for SearXNG |
| `maxResults` | integer | `5` | Results per search (1–10) |