READMESource: main@1571b37c
dsh-image-gen
DeepSeek Harness 图片生成插件:通过阿里云百炼(Qwen-Image)为 DSH agent 提供图片生成能力。
为 agent 注册一个 generate_image 工具:给定文字描述,调用百炼文生图服务生成图片,
并把图片作为对话附件返回——图片直接显示在对话流里,模型也能在后续步骤中查看。
起因:DSH 官方目前没有内置图片生成工具("完全没办法生成图片"是现状)。 本插件用百炼 CLI(
bl)作为后端,是官方推荐的生态贡献方式(dsh-plugintopic)。
前置条件
- 安装 阿里云百炼 CLI(
npm install -g bailian-cli)并登录:bl auth login --config token-plan --api-key <your-api-key> bl auth status # 确认已登录 - 确认能出图:
bl image generate --prompt "a cat" --out-dir ./out
安装
dsh plugin --profile <name> add github:haimuhaimu/dsh-image-gen
GitHub 安装时 pnpm 会拦截 prepare 脚本(本插件无构建,脚本仅打印提示);
如被拦截,按报错提示把包键加入 profile 的 pnpm-workspace.yaml 的 allowBuilds,再重新 add。
也可以本地安装:
dsh plugin --profile <name> add ./image-gen
使用
装好后 agent 会自动获得 generate_image 工具,直接对 DSH 说"生成一张……的图片"即可。
工具参数:
| 参数 | 必填 | 说明 |
|---|---|---|
prompt |
✅ | 图片描述(越详细越好:主体、风格、构图、光线) |
size |
尺寸:比例 3:4 / 16:9 / 1:1 或像素 1024*1024、2048*2048;默认 1024*1024 |
|
model |
模型:默认 qwen-image-3.0;可选 wan2.6-t2i、z-image-turbo 等 |
|
n |
生成数量(1-6),默认 1 | |
negative_prompt |
排除的元素 | |
seed |
随机种子,可复现结果 | |
watermark |
是否保留水印,默认 false |
配置
cordis.patch.yml 的 config 块:
- id: image-gen
name: dsh-image-gen
config:
blPath: "" # bl CLI 路径;留空自动查找 PATH 与常见安装位置
实现说明
- 工具注册:
ctx.tools.register(defineTool({...}))(@deepseek-ai/dsh-tools) - 图片保存:
ctx.attachments.saveImage()(@deepseek-ai/dsh-attachment),返回ImageAttachmentRef - 输出:
output.render返回[{ type: 'image', attachment: ref }, { type: 'text', ... }] - 执行:spawn
bl image generate --output json,解析saved路径,读回字节存为附件 - 取消/超时:监听
exec.signal与 10 分钟超时
No comments yet. Be the first to write one.