dsh-plugin-deepseek-search:在 DSH 中接入 DeepSeek 官方 Search / Fetch API

前言

在 DeepSeek Harness(DSH)裏做需要實時網頁信息的智能體時,常見做法是使用內置的 web_search / web_fetch,或自行封裝第三方搜索與抓取。若你希望模型直接調用 DeepSeek 自研搜索引擎 與 官方網頁抓取接口,並把結果以獨立工具名暴露給會話,而不改動 DSH 內置的 ctx.web 配置,就需要一個專門對接 POST https://api.deepseek.com/v1/tools/search 與 POST https://api.deepseek.com/v1/tools/fetch 的插件。

下面介紹社區插件 dsh-plugin-deepseek-search(維護者 lxyztmds),它把上述兩個 API 註冊爲 deepseek_search 與 deepseek_fetch,與內置聯網工具互不衝突。

這是什麼

dsh-plugin-deepseek-search 是 DSH 的 Host 端插件(npm 包名 dsh-plugin-deepseek-search,當前資料中版本爲 0.1.1,MIT 許可證)。簡介爲:Official DeepSeek Search / Fetch API tools for DeepSeek Harness (DSH)。

插件只讀、無緩存、無遙測,不會寫入工作區。鑑權默認通過 DSH 憑據服務解析 DEEPSEEK_API_KEY(可配置 apiKeyEnv);也可顯式配置 apiKey 字面值,此時優先使用字面值。換 Key 無需重啓進程。

接口說明見 DeepSeek 文檔:https://api-docs.deepseek.com/zh-cn/guides/search/。

核心功能

安裝後,模型在工具列表中會多出兩個工具:

工具 底層接口 作用
deepseek_search POST https://api.deepseek.com/v1/tools/search 檢索網頁,返回標題、URL、摘要、發佈時間、權威性、排序分等;可選返回網頁正文
deepseek_fetch POST https://api.deepseek.com/v1/tools/fetch 抓取單個網頁,返回標題與 Markdown 正文

與 DSH 內置 web_search / web_fetch 的關係:本插件使用獨立工具名,不接管內置 provider,也不修改內置設置。

deepseek_search 主要參數:

  • query(必填):1–128 個 Unicode 字符,支持 site:、-site:、引號精確短語、lang:、after: / before: 等語法(原樣傳給搜索服務)。
  • count(可選):1–50,未傳時使用配置默認值。
  • need_content(可選):是否同時返回網頁正文(更大、更慢)。

deepseek_fetch 主要參數:

  • url(必填):絕對 http(s) URL,≤8192 字符,須帶 host,不能攜帶用戶名/密碼。

HTTP 客戶端側支持超時、重試(408 / 429 / 5xx 與網絡錯誤)、響應校驗;錯誤會映射爲帶 [CODE] 前綴的文本(如 MISSING_CREDENTIAL、TIMEOUT),便於模型與日誌排查。Web 端可通過 presentationMeta / presentResult 展示結果卡片。

安裝與啓用

DSH 插件以 profile 的 bundle 形式加載:profile 的 package.json 在 dsh.profile.bundles 中引入本包,cordis.patch.yml 將插件行插入加載樹。

推薦:在 DSH 側邊欄 插件 → 發現 中搜索本插件;或在非 desktop profile 下使用命令行:

# GitHub 源碼安裝
dsh plugin --profile <profile-name> add github:lxyztmds/dsh-plugin-deepseek-search

# npm 安裝(發佈 npm 後可用)
dsh plugin --profile <profile-name> add dsh-plugin-deepseek-search

圖形界面本地路徑安裝(即時生效,適合 Desktop):

  1. 打開 插件 頁;
  2. 在安裝輸入框填入插件目錄的絕對路徑;
  3. 安裝後默認啓用;純 Host 端插件在 HMR 模式下通常會在後續會話中出現在工具列表。

非 Electron 託管的 profile 也可用本地路徑:

dsh plugin --profile <profile-name> add "file:C:\path\to\dsh-plugin-deepseek-search"
# 然後重啓該 profile

注意:desktop profile 由 Electron 獨佔,獨立 dsh CLI 會拒絕對其執行 add;Desktop 用戶優先用圖形界面或 README 中的手工 bundle 方式。資料要求 Node ^22.19.0 || >=24.0.0,DSH >=0.1.5-rc.1。

配置要點

可在 profile 的 cordis.patch.yml 中按插件 id deepseek-search 覆蓋配置,例如:

- id: deepseek-search
  config:
    apiKeyEnv: DEEPSEEK_API_KEY
    count: 5
    needContent: false
    timeoutMs: 60000
    retries: 2
    maxOutputChars: 60000

常用字段(完整表見倉庫 README):

字段 默認值(schema) 含義
apiKeyEnv DEEPSEEK_API_KEY 憑據引用名,經 ctx.credentials 解析
count 10 deepseek_search 未傳 count 時的默認條數
needContent false 未傳 need_content 時的默認是否拉正文
timeoutMs 60000 單次調用總預算(含重試)
retries 2 可重試錯誤的次數
maxOutputChars 60000 返回給模型的最大字符數
sendOriginalQuestion true 是否將本輪用戶問題前 128 字符作爲 ori_question 發送

API Key 解析順序:apiKey 字面值 → ctx.credentials.resolve(apiKeyEnv)(如 ~/.dsh/.credentials.yaml 或 Web 模型頁)→ 進程環境變量。三者皆無時,工具仍可見,執行時返回 MISSING_CREDENTIAL 及修復指引。

典型用法

在已配置 Key 且插件啓用的會話中,模型可按任務自行調用工具,例如:

  1. 用 deepseek_search 查詢:query 爲 DeepSeek site:github.com,必要時設 count 或 need_content: true 獲取正文。
  2. 對某條結果的 url 調用 deepseek_fetch,得到 Markdown 正文供後續推理。

搜索語法示例(來自 README):

DeepSeek site:github.com OR site:huggingface.co
DeepSeek -site:example.com
DeepSeek "精確短語" lang:zh,en after:2025-01-01 before:2026-06-01

計費與限速以 DeepSeek 文檔爲準:Search / Fetch 按成功請求次數計費;賬號側 Search、Fetch 各自約 5 QPS。本插件爲顯式工具調用路徑,請控制調用頻率與 count。自 2026-11-01 00:00(北京時間) 起,在部分宿主環境中的服務端工具調用也將按次收費(詳見 README「計費與限速」)。

適用場景與注意

適合:已在 DSH 中使用 DeepSeek API Key,希望用官方 Search / Fetch 做聯網檢索與單頁抓取,且希望與內置 web_search / web_fetch 並存、由模型按工具名選擇。

使用前請知悉:

  • 插件以當前 DSH 進程的權限運行;query、url 會發往 DeepSeek API。安裝前請閱讀 GitHub 倉庫 源碼與 MIT 許可證,確認符合你的安全與合規要求。
  • 頁面正文視爲外部不可信數據;插件不執行頁面腳本。baseURL 非 https 時會明文傳輸 Key,僅應指向可信網關。
  • 社區目錄 SkillHub 插件頁 與 DeepSeek / 幻方無官方從屬關係,屬於 DSH「一切皆插件」生態中的第三方條目(資料中 GitHub 星標爲 1,分類:聯網工具)。

結尾

dsh-plugin-deepseek-search 把 DeepSeek 官方 Search / Fetch 以 deepseek_search、deepseek_fetch 兩個只讀工具接入 DSH,配置憑據與超時後即可在會話中使用,且不干擾內置聯網設置。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜