前言¶
DeepSeek Harness(DSH)里,模型调用的仍是内置的 web_search 工具,真正决定「搜什么、返回什么」的是你在 Cordis 里选中的搜索提供方(provider)。若把官方 deepseek-official 指到经 CLIProxyAPI 转发的 Gemini,搜索能跑,但 grounding 结果里的来源链接往往是 vertexaisearch.cloud.google.com/grounding-api-redirect/… 这类跳转地址;后续 web_fetch 无法按预期跟进,摘要也只取每个链接的第一段引用,整体不好用。
alanzhao0128/dsh-web-search-gemini 是社区维护的联网工具类插件:provider id 为 cpa-gemini,向 ctx.web 注册搜索提供方,不新增工具名。选中它之后,模型侧仍是 DSH 原生 web_search,后端改为经 CLIProxyAPI 的 Anthropic 兼容 /v1/messages 调用 Gemini 的 Google 搜索(grounding),并在返回前把符合条件的跳转链接解析为真实 URL。
这是什么¶
- 包名:
@alanzhao/dsh-web-search-gemini(npm 未发布,需本地构建后以link:挂入 profile) - 维护者:alanzhao0128
- 分类:联网工具(社区目录 SkillHub 插件页)
- 源码与文档:GitHub,MIT 许可,当前资料中版本为
0.1.1
插件只做一件事:在配置 web.searchProvider: cpa-gemini 时,接管 web_search 的后端实现。
与「官方指向 Gemini」的差异¶
资料里用表格概括了和「官方 deepseek-official 直接指向 Gemini」的对比,核心如下。
| 方面 | 官方 deepseek-official 指向 Gemini | 本插件 cpa-gemini |
|---|---|---|
| 来源链接 | 常为 grounding 跳转链接,web_fetch 难以跟进 |
可选将跳转还原为真实网址 |
| 摘要 | 每个链接只取第一段引用 | 同一链接的多段引用合并、去重,以 … 连接 |
| 模型总结 | 丢弃 | 可选返回,并带固定前缀便于核对 |
跳转还原只读 HTTP 响应头里的 location,不访问目标站点;仅处理 vertexaisearch.cloud.google.com 域名;失败或超时保留原链接,不阻断搜索。每次搜索会在会话中记录 web/cpa-gemini-search-request 事件(endpoint、apiVersion、请求体,不含密钥)。
前提条件¶
- 已有可用的 CLIProxyAPI 实例,账号池含 Gemini,且能把 Anthropic 格式的
web_search_20250305转成 Gemini Google 搜索。自测方式:向<baseURL>/messages发带该工具的请求,响应中应出现web_search_tool_result块。 - DSH 版本与插件 peer 依赖一致,资料写明为 0.2.1-rc.5 前后(
@deepseek-ai/dsh-web等 peer 按此声明)。 - Node >= 22(见 package.json
engines)。
配置说明¶
Cordis 补丁行 id 为 web-search-gemini。字段在每次搜索时重新读取,改完配置无需重启 DSH(但若尚未加载插件就指向 cpa-gemini,会出现 WEB_PROVIDER_CONFIGURED_MISSING)。
在 ~/.dsh/profiles/desktop/cordis.patch.yml(或你使用的 profile)中,除插件块外,还需把 @deepseek-ai/dsh-web 的 searchProvider 设为 cpa-gemini;抓取仍可用本地 HTTP 提供方,例如:
- id: web
name: "@deepseek-ai/dsh-web"
config:
searchProvider: cpa-gemini
fetchProvider: http
- id: web-search-gemini
name: "@alanzhao/dsh-web-search-gemini"
config:
baseURL: https://<your-cliproxy-host>/v1
apiKeyEnv: CLIPROXY_API_KEY
baseURL 为必填,须含 /v1,请求发往 baseURL + "/messages"。密钥通过 apiKeyEnv(默认 CLIPROXY_API_KEY)从 DSH credentials(~/.dsh/.credentials.yaml 的 refs)或启动环境解析;也可用 apiKey 明文,资料不推荐。
其余默认值与含义(摘自 README):
| 字段 | 默认值 | 说明 |
|---|---|---|
model |
gemini-3.8-flash-high |
按 CLIProxyAPI 模型列表填写 |
apiVersion |
2023-06-01 |
anthropic-version 头 |
maxTokens |
4096 |
生成上限 |
maxUses |
2 |
单次请求内模型最多搜索次数 |
resolveRedirects |
true |
是否还原 grounding 跳转链接 |
resolveTimeoutMs |
5000 |
单链接解析超时(毫秒) |
includeAnswer |
true |
是否返回模型总结 |
answerMaxChars |
1200 |
总结字数上限 |
snippetMaxChars |
300 |
单条摘要字数上限 |
安装与启用¶
本包未发布到 npm。资料给出的步骤是克隆仓库、构建,再用 link: 写入 profile(以下以 desktop profile 为例)。安装前请自行阅读源码与 MIT 许可证;插件以当前 DSH 进程权限运行。
git clone https://github.com/alanzhao0128/dsh-web-search-gemini.git
cd dsh-web-search-gemini
npm install && npm run build
- 编辑
~/.dsh/profiles/desktop/package.json:增加依赖并加入 bundles,在该目录执行pnpm install。
{
"dependencies": {
"@alanzhao/dsh-web-search-gemini": "link:/path/to/dsh-web-search-gemini"
},
"dsh": { "profile": { "bundles": ["@alanzhao/dsh-web-search-gemini"] } }
}
-
完整退出并重启 DSH,使插件加载。
-
在
cordis.patch.yml中填写上文 web 与web-search-gemini配置。这一步改完不用重启;若在第 2 步之前就改好,插件未加载前搜索会报错。
典型用法¶
对智能体与 preset 而言,没有新工具名:在会话里照常触发 DSH 的 web_search。区别仅在于结果形态——来源 URL 可被还原、摘要可合并、可选附带带前缀的模型总结:
Search summary (model-generated; verify against sources):
模型并发多个查询时,仍受 DSH agent preset 里约 60 秒的整体时限约束;最慢的一条失败会导致整次 web_search 失败,模型往往会自行重试。资料未提供单独的「一键演示命令」,验证路径是:配置完成后在 Agent 中发起需要联网的任务,或在插件目录执行 smoke(需真实端点):
SMOKE_BASE_URL=https://<your-cliproxy-host>/v1 SMOKE_API_KEY=<key> npm run smoke
适用场景与注意¶
适合谁:已有 CLIProxyAPI + Gemini、希望继续用 DSH 原生 web_search / web_fetch 工作流,又需要 grounding 链接可抓取、摘要更完整的使用者。
务必注意:
- 不要打开 DSH「网页搜索」设置页的开关。 该页会把
searchProvider/fetchProvider改成 DeepSeek 收费 Search / Fetch API,只管理官方提供方。 - 无自动回退。 选中的提供方不可用时,
web_search直接报错,不会切换其他提供方。 - 延迟与模型选择。 资料称
gemini-3.8-flash-high单次搜索约 20–70 秒且波动大;换gemini-3-flash约 3–4 秒但总结更浅。整体 60 秒时限只能覆盖 preset 才能改。 - 主模型网关。 部分 Anthropic 兼容网关会清空
web_search工具参数,出现missing required property "queries",发生在主模型侧,与本插件无关。
回滚:仅换回官方搜索时,把 web.searchProvider 改回默认 deepseek-official,无需重启。完全移除时,删掉 cordis.patch.yml 中的 web-search-gemini 行,并从 profile 的 dependencies 与 dsh.profile.bundles 去掉本包,pnpm install 后重启 DSH。
结尾¶
DSH 生态里,搜索后端可以插件化替换;社区目录 SkillHub 与 DeepSeek / 幻方无官方从属关系。若你的瓶颈是 Gemini grounding 跳转链与摘要格式,而不是「要不要联网」,可以在自备 CLIProxyAPI 的前提下试用 cpa-gemini。细节与变更以仓库 README 为准:https://github.com/alanzhao0128/dsh-web-search-gemini。