前言¶
DSH 中面向模型的 web_search 通常從 dsh-tool-web 進入 ctx.web.search(),再落到一個已註冊的搜索 provider。已發佈的 web-search-deepseek provider 只處理 Anthropic 兼容的 /messages API 和 web_search_20250305。
如果你的自定義模型走 OpenAI Responses 端點,並且該端點本身支持內置 web_search,單靠普通配置還不能把 DSH 的搜索請求轉到這個端點。dsh-web-search-responses 就是爲這個場景提供的 DSH ctx.web 搜索 provider。
這是什麼¶
dsh-web-search-responses 是 herminger 維護的 DSH 插件,許可證爲 MIT。
它註冊一個名爲 responses-web 的搜索 provider,讓 ctx.web.search() 複用當前會話模型使用的 Responses API 端點,併發送內置 web_search 請求。
核心能力¶
下面介紹這個插件已覈實的主要能力:
- 註冊
responses-webprovider,向會話模型使用的 Responses API 端點發送web_search請求。 - 使用
type爲web_search的tools與tool_choice。 - 解析響應中的
web_search_call項與消息引用,並轉換回 DSH 標準WebSearchResult。 - 默認自動跟隨當前模型/路由,也可以顯式固定
llm-pi-ai路由。 - 支持配置
provider、model、baseURL、apiKeyEnv、includeSources、searchContextSize、toolChoice、maxOutputTokens。
安裝與啓用¶
從 GitHub 安裝¶
從 GitHub 安裝推薦要求 pnpm 在 PATH 上。先確認 pnpm 可用,再執行:
dsh plugin --profile web add github:herminger/dsh-web-search-responses
如果之前安裝過本地鏈接副本,並想切換到 GitHub 源,先移除舊安裝,再執行 GitHub 安裝:
dsh plugin --profile web remove dsh-web-search-responses
dsh plugin --profile web add github:herminger/dsh-web-search-responses
從本地檢出安裝¶
如果你已有本地檢出,可以直接添加本地路徑:
dsh plugin --profile web add /path/to/dsh-web-search-responses
如果沒有 pnpm,也可以先用 patch 做快速測試。overlay.patch.yml 需要與 index.mjs 同目錄,或者使用絕對路徑:
dsh --profile web --patch /path/to/overlay.patch.yml
安裝或變更後,完全重啓 dsh web,讓新 bundle 生效。
典型用法¶
默認情況下,這個 provider 會自動跟隨當前模型:
provider和model可以來自執行 agent、DSH 默認模型,或唯一配置的llm-pi-aiResponses 路由。baseURL和apiKeyEnv可以來自該路由的llm-pi-ai設置。
如果要顯式固定路由,可以編輯 profile 的 cordis.patch.yml,把 id 爲 web-search-responses 的 provider 固定爲 cpa:
- id: web-search-responses
config:
provider: cpa
常用配置項如下:
| 字段 | 含義 | 默認值 |
|---|---|---|
provider |
要複用的 llm-pi-ai 路由 |
當前模型路由 |
model |
搜索請求使用的模型 | 當前模型 |
baseURL |
Responses 端點前綴,會自動追加 /responses |
路由 baseURL |
apiKeyEnv |
憑據引用,例如 CPA_API_KEY |
路由 apiKeyEnv |
includeSources |
是否發送 include: ["web_search_call.action.sources"] |
false |
searchContextSize |
low / medium / high |
未設置 |
toolChoice |
{ type: "web_search" } 或 "required" |
{ type: "web_search" } |
maxOutputTokens |
搜索請求的輸出 token 上限 | 4096 |
排障¶
configured web provider "responses-web" is registered but unavailable:通常是插件 config 被解析爲 YAMLnull,例如空config:。更新到最新index.mjs,其中會對config ?? {}做歸一化,然後重啓 DSH。Responses API returned no web_search_call item:說明該端點/模型實際不支持內置web_search工具。no API key for "...":檢查路由的apiKeyEnv,以及 DSH 中保存的憑據。
適用場景與注意¶
這個插件適合會話模型的 Responses 端點已經支持內置 web_search 的場景。通過它,DSH 的 ctx.web 搜索請求可以直接複用當前會話模型使用的端點,而不再依賴 Anthropic Messages 兼容的搜索 provider。
安裝前建議檢查源碼與 MIT 許可證。插件會在當前 dsh 進程權限下運行,涉及 API key、路由、模型和網絡請求時,應確認這些配置符合預期。
參考¶
GitHub 倉庫:https://github.com/herminger/dsh-web-search-responses
目錄頁可通過插件名 dsh-web-search-responses 檢索。