Skip to content
dsh.fish
Bundle

dsh-imggen

DeepSeek Harness plugin: text-to-image output with in-chat image cards, download button, history gallery, and provider selection tabs

Source
Stellight
stars
1 stars
License
MIT
Updated
Updated 13 days ago

Readme

# dsh-imggen

DeepSeek Harness 静态 dual-face 插件:为 DSH 提供**文生图输出**能力(与 `dsh-deepseek-balance` 同款 profile bundle 机制,重启不丢失、无需批准)。

## 功能

- **`generate_image` 模型工具**:从文本提示生成图片并在对话工具卡片中直接渲染;
  - 默认后端 **Pollinations**(免费、无需 API Key);
  - 可选后端 **OpenAI**(DALL·E 3,需要 `OPENAI_API_KEY` 或 `DSH_OPENAI_API_KEY` 环境变量 / DSH 凭证库);
  - 参数:`prompt`(必填)、`provider`、`size`(square/landscape/portrait)、`model`、`seed`;
- **下载按钮**:工具卡片上一键下载(浏览器侧 fetch → blob → 保存;跨域失败自动回退到新标签页打开);
- **历史图片画廊**:`🖼 历史` 按钮打开悬浮画廊,网格缩略图 + 提示词 + 删除/清空,存于浏览器 localStorage(跨重启保留);
- **API 选择选项卡**:输入框工具行右侧的 `🎨 Pollinations | ✨ OpenAI` 分段控件;选择经同源 HTTP 路由同步到 Host,并通过 `systemPrompt` 变量注入模型提示词,模型默认按选项卡选择调用后端。

## 架构(dual-face,无构建步骤)

| 文件 | 半区 | 说明 |
| --- | --- | --- |
| `dsh/index.js` | Host | ESM 插件:注册 `generate_image` 工具、`systemPrompt` 变量/节、同源路由 `/dsh-imggen/pref`;OpenAI 调用与 Pollinations 验证走 Node 原生 `fetch` |
| `dsh/client.js` | Client | 手写 lazy-CJS bundle(`window.__ModuleLoader__.load`):工具卡片、历史画廊 overlay、生图 API 选项卡 |

## 安全说明

- 仓库代码不含任何 API Key;OpenAI Key 按 `credentials` 服务 → `OPENAI_API_KEY`/`DSH_OPENAI_API_KEY` 环境变量顺序解析,仅在本地进程内用于官方接口调用。

## 安装(dsh profile bundle)

1. 把本包放入 profile 的 `node_modules`(默认 profile:`~/.dsh/profiles/web/`):
   - 方式 A:`dsh plugin --profile web add <本包路径>`(pnpm 转发,自动 reconcile 进 bundles);
   - 方式 B:手动复制到 `~/.dsh/profiles/web/node_modules/dsh-imggen/`;
2. 编辑 profile 的 `package.json`:
   ```json
   {
     "dependencies": { "dsh-imggen": "1.0.0" },
     "dsh": { "profile": { "bundles": ["…", "dsh-imggen"] } }
   }
   ```
3. 重启 harness(`dsh web`)。工具卡片、画廊、选项卡自动生效。

## License

MIT

Install

dsh plugin --profile web add github:Stellight/dsh-imggen

Profile: web

  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source