dsh-image-plugins:爲 DeepSeek Harness 接入看圖與生圖

前言

DeepSeek Harness(DSH)通過插件擴展能力。如果要在 DSH 的 web profile 中使用圖片理解或圖片生成,需要先接入相應的模型端點。

下面介紹 dsh-image-plugins。它爲 DeepSeek Harness 提供兩類多模態能力:理解工作區中的圖片文件,並根據提示詞生成圖片。這兩個能力都通過可配置的 OpenAI-compatible 或 DashScope 端點完成。

這是什麼

alanzhao0128/dsh-image-plugins 是一個 DeepSeek Harness 多模態插件,由 alanzhao0128 維護,採用 MIT 許可證。

它提供兩個核心能力:

  • understand_image:讀取工作區圖片文件,發送到可配置的視覺端點,並返回模型的文字描述。
  • generate_image:根據提示詞生成圖片,保存到工作區並返回保存路徑。

插件的 vision 與 image 配置塊相互獨立。未配置時,對應能力不啓用;未配置安裝保持 inert and safe。

核心功能

understand_image

understand_image 是一個 model tool。它會讀取工作區中的圖片文件,把圖片發送到配置的視覺端點,並返回模型生成的文字描述。

這個能力適合在文本流程中討論截圖、圖表、界面截圖或其他工作區圖片。

generate_image

generate_image 也是一個 model tool。它根據提示詞調用圖片生成端點,把生成結果保存到工作區,並返回保存路徑。

在默認示例中,生成圖片保存到 generated/。

DashScope 圖片生成

插件支持任意 OpenAI-compatible 端點,並支持可選的 DashScope provider,用於調用 native Model Studio API。

需要注意:DashScope compatible-mode 不提供 images/generations,會返回 404。因此使用 DashScope 做圖片生成時,需要使用 provider: dashscope 的 native Model Studio API。

安裝與啓用

安裝

使用官方安裝命令:

dsh plugin --profile web add dsh-image-plugins

安裝後重啓 dsh web,或重啓對應 profile 進程。

啓用能力

插件安裝後並不會自動啓用能力,需要先配置端點和密鑰。

自 0.2.0 起,插件提供 Web settings panel:

Settings → 圖片插件 / Image Plugins

在這個面板中,可以編輯 vision 與 image 兩個配置塊,並通過官方 credential store 管理對應密鑰。

也可以手動配置。在 profile 的 cordis.patch.yml 中覆蓋 id: image-plugins 行,並設置 vision 與 image 的 baseUrl、apiKey、model 等配置。

一個基礎配置示例:

- id: image-plugins
  name: dsh-image-plugins
  config:
    vision:
      baseUrl: 'https://your-vision-endpoint.example.com/v1'
      apiKey: 'sk-...'
      model: 'your-vision-model'
    image:
      baseUrl: 'https://your-image-endpoint.example.com/v1'
      apiKey: 'sk-...'
      model: 'your-image-model'

如果只需要看圖,可以只配置 vision。如果只需要生圖,可以只配置 image。兩個配置塊相互獨立。

配置與密鑰

配置塊獨立

vision 與 image 是獨立配置塊。每個 config block 可以單獨啓用,也可以一起啓用。

部分填寫會 fail the load loudly。例如只寫了 baseUrl,但沒有寫 apiKey,加載會明顯失敗。

apiKey 支持的寫法

apiKey 支持三種形式:

'sk-...'
env:VARNAME
cred:NAME

其中 cred:NAME 會在每次請求時通過宿主 credential seam 解析。

密鑰不會進入 session log 或 tool results。

端點要求

端點必須 OpenAI-compatible。

視覺理解使用:

POST {baseUrl}/chat/completions

並要求端點接受 image_url data URL。

圖片生成使用:

POST {baseUrl}/images/generations

並要求端點返回:

data[0].b64_json

或:

data[0].url

DashScope 配置注意

DashScope compatible-mode 不提供 images/generations,會返回 404。

如果要做 DashScope 圖片生成,需要使用 provider: dashscope 的 native Model Studio API。

典型用法

看圖

在 workspace 中輸入:

Look at `images/screenshot.png` and tell me what it shows.

插件會讀取該圖片文件,調用配置的視覺端點,並返回模型的文字描述。

生圖

在 workspace 中輸入:

Generate an image of a red apple on a wooden table.

插件會調用圖片生成端點,保存圖片到工作區,並返回保存路徑。示例中保存目錄爲 generated/。

圖生圖

圖生圖需要 DashScope provider。示例提示詞:

Change the color of `images/logo.png` to blue.

適用場景與注意

適合誰

這個插件適合以下場景:

  • 需要在 DSH web profile 中理解工作區圖片。
  • 需要基於提示詞生成圖片,並把結果保存回工作區。
  • 希望視覺端點和圖片生成端點分開配置。
  • 希望密鑰不進入 session log 或 tool results。
  • 希望未配置時插件保持 inert and safe。

安全與許可證

包內不攜帶 API keys,每個用戶自行配置。

插件以當前 dsh 進程權限運行。安裝前應先檢查源碼與許可證。

許可證爲 MIT。

其他注意

  • Auto-understand (V2) 已實現,但默認關閉,未經 live session 驗證,不屬於 supported surface。
  • 從 GitHub 安裝時,如果環境是 pnpm ≥ 10,需要先允許構建腳本,然後重新 add。
  • npm 與 tarball 安裝無需該允許。

pnpm allowBuilds 配置示例:

allowBuilds:
  dsh-image-plugins: true

結尾

dsh-image-plugins 把圖片理解和圖片生成接入了 DSH 插件體系:看圖能力返回文字描述,生圖能力返回工作區保存路徑。兩個能力獨立配置,密鑰通過 credential 機制處理,未配置時不會啓用。

相關鏈接:

  • 目錄頁:https://www.skillhub.cn/plugins/alanzhao0128/dsh-image-plugins
  • GitHub:https://github.com/alanzhao0128/dsh-image-plugins
羽毛球分组比赛记分
小程序二维码

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

小夜