Skip to content

dsh-plugin-image-gen

Verified

dsh-plugin-image-gen · v0.2.0 · MIT · Web UI

Image and video generation for DeepSeek Harness: routes image models to /images/generations and video models to the async /videos API, exposing image_generate and video_generate tools plus a composer text/image/video output-mode switch.

Install

dsh plugin add dsh-plugin-image-gen

Confirm the layer applied with dsh --profile default --dump-config — see the install guide.

Source

Published to npm without a public repository. Inspect the package contents before installing.

Tags

Creators

Readme

dsh-plugin-image-gen

给 DeepSeek Harness 补上图像生成与视频生成两个能力,并在输入框里加一个**「文本 / 图像 / 视频」输出模式下拉框**。

这是本机正在使用的 dsh-plugin-image-gen 的独立分发包,可以直接装到同事电脑的 DSH 上。


这个插件解决什么问题

DSH 的对话模型通道(dsh-llm-pi-ai)只讲三种 chat 协议。而 Agnes 的 agnes-image-*、agnes-video-* 是生成模型,走的是另外的端点:

能力 端点 形态
图像 POST {baseURL}/images/generations 同步返回,几十秒
视频 POST {baseURL}/videos 建任务 + GET {apiRoot}/agnesapi?... 轮询 异步,几分钟

所以生成模型不能放进对话模型选择器——一旦选中,DSH 会发一个 chat 请求,上游直接拒绝:

400 ... is an image model, use /v1/images/generations

本插件把这条缺失的通道单独接出来:

  • Host 端(lib/index.js):注册 image_generate 和 video_generate 两个工具,各自调用正确的端点,并把结果下载成工作区里的真实文件(不是丢一个会过期的 CDN 链接)。
  • Client 端(lib/client.js):在输入框内、和「工作区内修改」同一视觉带里,加一个输出模式下拉框。选「图像」或「视频」后可以再选具体模型,选择记在浏览器本地。

安装

方式零:从 npm 安装(推荐,可被搜索到)

在 DSH 侧边栏 插件 页面的安装框里输入包名:

dsh-plugin-image-gen

DSH 会自己完成 pnpm add、写 profile 配置、启用 bundle,不需要跑下面的脚本。

这条路的前提是这个包已经发布到 npm。若搜索不到,见仓库根目录的 PUBLISH.md。

方式一:一键脚本(本地 zip / 文件夹)

.\install.ps1

# 若提示"禁止运行脚本"
powershell -NoProfile -ExecutionPolicy Bypass -File .\install.ps1

脚本会:

  1. 把本包复制到 <profile>\plugins\dsh-plugin-image-gen\
  2. 在 profile 的 package.json 里加上 bundles 条目和 file: 依赖
  3. 修改前先备份 package.json

指定 profile:

.\install.ps1 -Profile "$env:USERPROFILE\.dsh\profiles\desktop"

脚本可重复执行,不会写重复条目。

方式二:手动安装

  1. 复制到 <profile>\plugins\dsh-plugin-image-gen\

  2. 编辑 <profile>\package.json:

    {
      "dsh": {
        "profile": {
          "bundles": [
            "@deepseek-ai/dsh-base",
            "@deepseek-ai/dsh-web-app",
            "dsh-plugin-image-gen"
          ]
        }
      },
      "dependencies": {
        "dsh-plugin-image-gen": "file:./plugins/dsh-plugin-image-gen"
      }
    }
    
  3. 重启 DSH。

本包自带 cordis.patch.yml,加进 bundles 后插件行会自动挂载。

⚠️ 装完必须做的一步:让对话模型选择器不要收录生成模型

这是最容易踩的坑。 如果你的 profile 里 llm-pi-ai 的 provider 模型列表把 agnes-image-* 或 agnes-video-* 也写进去了,用户一旦在对话模型下拉框里选中它,那一轮对话就会以 400 报错结束。

检查 <profile>\cordis.patch.yml 的 llm-pi-ai 段,确保只列 chat 模型:

- id: llm-pi-ai
  name: "@deepseek-ai/dsh-llm-pi-ai"
  config:
    providers:
      agnes:
        displayName: agnes
        apiKeyEnv: AGNES_API_KEY
        api: openai-completions
        baseURL: https://api.agnes-ai.cn/v1
        models:
          - id: agnes-2.5-flash
            name: agnes-2.5-flash
          # 只列 chat 模型。图像/视频模型交给 dsh-plugin-image-gen,
          # 它在自己的输出模式下拉框里提供。

配置 API Key(必做)

插件默认从配置的 apiKeyEnv(默认 AGNES_API_KEY)取密钥,不会把密钥写进分发包。

三种方式,任选其一:

A. DSH 凭证库(推荐)

在 DSH 设置界面里添加凭证,名字用 AGNES_API_KEY。插件每次调用时实时解析,改完立即生效,不用重启。

B. 环境变量

# 当前会话临时生效
$env:AGNES_API_KEY = "your-key-here"

# 永久写入用户环境变量(重开终端生效)
[Environment]::SetEnvironmentVariable("AGNES_API_KEY", "your-key-here", "User")

C. 直接写进插件配置

在 profile 的 cordis.patch.yml 里:

- id: image-gen
  config:
    apiKey: "your-key-here"

方式 C 会让密钥以明文落在 profile 配置里,仅在你确认该机器可信时使用。

密钥缺失时工具会明确报错,不会发一个没带认证的请求:

image_generate has no credential: set apiKey in the plugin config, or make AGNES_API_KEY resolvable

配置项

本包 cordis.patch.yml 的默认值:

- insert:
    - id: image-gen
      name: dsh-plugin-image-gen
      config:
        provider: agnes
        displayName: Agnes Images
        baseURL: https://api.agnes-ai.cn/v1
        apiKeyEnv: AGNES_API_KEY
        defaultModel: agnes-image-2.5-flash
        models:
          - agnes-image-2.5-flash
          - agnes-image-2.1-flash

完整可配字段:

字段 默认值 说明
provider agnes 路由键,也是日志里的标签
displayName Agnes Images 显示名
baseURL https://api.agnes-ai.cn/v1 OpenAI 兼容 API 根,不含 /images/generations
apiKeyEnv AGNES_API_KEY 凭证引用名
apiKey 空 直接写死密钥(不推荐)
models 2 个 image 模型 允许服务的图像模型
videoModels 2 个 video 模型 允许服务的视频模型
defaultModel agnes-image-2.5-flash 未指定时用的图像模型
defaultVideoModel agnes-video-2.5 未指定时用的视频模型
defaultSize 空 默认像素尺寸,留空由上游决定
timeoutMs 300000 单次图像请求上限
videoTimeoutMs 900000 单个视频任务总上限(含轮询)
videoPollMs 4000 视频状态轮询间隔
headers {} 合并进每个请求的额外请求头

覆盖配置:在 profile 的 cordis.patch.yml 里按 id 改。

换成别的服务商

任何 OpenAI 兼容的服务商都能用,改 baseURL / apiKeyEnv / models / defaultModel 即可:

- id: image-gen
  config:
    displayName: My Images
    baseURL: https://api.example.com/v1
    apiKeyEnv: MY_IMAGE_KEY
    models: [my-image-model]
    defaultModel: my-image-model

视频部分目前是按 Agnes 的异步协议写的(建任务 + /agnesapi 轮询)。换服务商时视频端点如不兼容,请只使用图像能力。


工具

image_generate

参数 必填 说明
prompt ✅ 完整视觉描述:主体、风格、构图、背景、不要出现什么
model 图像模型 id,默认 defaultModel
size 宽x高,如 1024x1024;省略由服务端决定
n 生成数量,1–8,默认 1
output_dir 输出目录,相对工作区或绝对路径,默认工作区根
filename 基础文件名(不含扩展名),默认取 prompt 的 slug

返回每个文件的 path、bytes、source。字节流会嗅探容器格式,扩展名与实际内容一致。

video_generate

参数 必填 说明
prompt ✅ 视频描述:主体场景、动作变化、镜头运动、风格、音频节奏
mode text(默认)/ keyframe / reference
model 视频模型 id,默认 defaultVideoModel
seconds 时长字符串 "4"–"12",默认 "5"
size 720P / 1080P / 1K / 2K,默认 720P
aspect_ratio 16:9 / 9:16 / 1:1 / 4:3 / 3:4 / 21:9,默认 16:9
first_frame / last_frame 首/尾帧公网 URL,仅 keyframe 模式
images 参考图公网 URL 数组(最多 8),仅 reference 模式
output_dir / filename 同 image_generate

模式参数会互相校验:keyframe 必须给首帧或尾帧,reference 至少给一张参考图,text 不接受任何图像输入。

视频是付费能力。 Agnes 账户没有余额时会直接报配额错误——这是上游的计费策略,不是插件故障。


输出模式下拉框

输入框内、和「工作区内修改」同一行的位置,多出一个下拉:

[● 文本]  [● 图像 · Agnes Image 2.5 Flash]  [● 视频 · Agnes Video 2.5]
  • 文本:对话与工具调用,模型由 DSH 原本的模型选择器决定(那里只该有 chat 模型)。
  • 图像:生成图片,二级面板选具体图像模型。
  • 视频:生成视频,二级面板选具体视频模型。

选择记在浏览器 localStorage,刷新后保留。一个模式如果自己有模型,选中后会直接钻进二级面板,让「模式 + 模型」这个组合是明确选定的。

Host 端始终是权威:即使前端的模型列表过期了,请求了不存在的模型也会被 Host 拒绝:

image_generate does not serve model "xxx"; configured models are: ...

所以改 Host 的 models 配置后,前端列表没同步也不会打错端点。


包结构

dsh-plugin-image-gen/
├── package.json          插件清单
│                          (dsh.bundle → cordis.patch.yml;dsh.client → lib/client.js)
├── cordis.patch.yml      挂载行与默认配置
├── install.ps1           安装脚本
├── README.md             本文件
└── lib/
    ├── index.js          Host:image_generate + video_generate 两个工具
    └── client.js         Client:输入框内的输出模式下拉框

常见问题

输入框里没有那个下拉框? Client 端会注入 @deepseek-ai/dsh-client-locale 和 @deepseek-ai/dsh-client-ui-conversation。确认这两个包在你的 profile 里存在(默认组合都有)。然后刷新页面——Client 端改动只在页面刷新后才生效。

报 400 ... is an image model, use /v1/images/generations? 说明你在对话模型下拉框里选中了生成模型。去 profile 的 cordis.patch.yml 把 llm-pi-ai 的 models 清成纯 chat 模型(见上面「装完必须做的一步」),然后用输入框左边的输出模式下拉框来选图像/视频。

报 has no credential? 钥匙没配好。见上面「配置 API Key」。

视频一直轮询超时? 默认总上限 15 分钟(videoTimeoutMs)。免费额度下排队久时,把它调大。

图像生成很慢正常吗? 正常,通常几十秒。timeoutMs 默认给了 5 分钟。

想一次生成多张? n 传 2–8,文件名会自动加 -1、-2 后缀。

生成的图片在哪? 不传 output_dir 就写在工作区根目录,文件名形如 <prompt-slug>-<时间戳>.png。绝对路径只在沙箱允许的位置可写。


许可

MIT。