Skip to content
dsh.fish
Bundle

dsh-plugin-gpt-load

DeepSeek Harness plugin that serves every gpt-load model from one provider group, each model on its own wire protocol (OpenAI Chat Completions or Anthropic Messages), synced from /api/models

Source
wesleyel
License
MIT
Updated
Updated 5 hours ago

Readme

# dsh-plugin-gpt-load

把 [gpt-load](https://github.com/tbphp/gpt-load) 的模型池接入 **DeepSeek Harness (dsh)**:自动同步当前 AccessKey 可见的全部模型及其能力,注册成**一个** provider 分组,每个模型各自使用 OpenAI 或 Anthropic 协议。

---

## 功能

- 🧩 **单一分组**:模型选择器里只有一个 **GPT-Load**,不再按协议拆成两个。
- 🎛️ **每模型可选协议**:默认按 gpt-load 返回的 `protocols` 字段判定,也可以在设置里把任意模型单独固定为 OpenAI 或 Anthropic,或恢复自动判定。
- 🔄 **自动同步**:启动时与定时从 `/api/models` 拉取模型池,无需逐条手写。
- 🧠 **能力自动填充**:上下文窗口、最大输出、多模态输入、Thinking 思考档位(low/medium/high)。
- 🔐 **密钥安全**:AccessKey 交给 harness 的 credentials 服务保存,不写入 `settings.yaml`。
- ⚙️ **无损写入**:同步只更新自己的 `gpt-load` 配置节,不破坏其余配置与注释。

> **为什么要插件自己实现?** harness 的 `llm-pi-ai` 把协议定在 provider 路由一级,模型条目上的协议会被忽略,所以「一个分组里混用两种协议」无法用 `settings.yaml` 表达。pi-ai 本身支持(`createProvider` 接受以 `model.api` 为键的实现表),本插件据此构建 provider,并交给 harness 自带的适配器处理请求翻译。

---

## 安装

```bash
cd ~/.dsh/profiles/web
npm install wesleyel/dsh-plugin-gpt-load
```

装进 harness profile(如 `~/.dsh/profiles/web`)即可,重启后生效。也可以指定本地路径:`npm install /path/to/dsh-plugin-gpt-load`。

运行时依赖(`@deepseek-ai/dsh-llm-pi-ai`、`@deepseek-ai/dsh-llm`、`@earendil-works/pi-ai`)由 harness 提供,插件启动时自动从 harness 安装目录解析;`npm install` 的 `prepare` 会自动完成构建。

---

## 配置

安装后重启 harness,在 **设置 → GPT-Load** 里填网关地址(例如 `http://127.0.0.1:3001`)与 AccessKey,点「立即同步模型」即可。

也可以在 profile 里预置:

```yaml
plugins:
  gpt-load-sync:
    endpoint: http://127.0.0.1:3001   # 可留空,稍后在 Web UI 填
    apiKey: gl-your-access-key        # 可留空,稍后在 Web UI 填
    displayName: GPT-Load             # 分组显示名
    defaultProtocol: auto             # auto | openai-completions | anthropic-messages
    syncOnStart: true
    syncIntervalMinutes: 60
```

### 协议判定规则

优先级从高到低:

1. **模型自身的 `protocol`**(设置里的显式选择,重启后保留);
2. 上游 `protocols` 只允许一种可服务协议 → 直接采用;
3. 上游允许两种 → 全局 `defaultProtocol` 生效则用它,否则取上游列表第一个(`auto`);
4. 上游未声明 → `openai-completions`。

只有 `openai-completions` 与 `anthropic-messages` 两种协议可服务,上游声明的 `openai-responses`、`gemini` 等会被忽略。

> 实际部署中模型往往同时声明两种协议,`auto` 会按上游顺序取第一个。想让 Claude 之类走 Anthropic,请在模型列表里单独选择,或把默认协议设为 `anthropic-messages`。

### 从旧版本升级

旧版本写入的 `llm-pi-ai` 路由(`gpt-load` / `gpt-load-anthropic`)会被自动接管:先还原 `endpoint`,再移除这两条路由。其余 provider 不受影响。

---

## 开发

```bash
npm install
npm run build    # tsc + 客户端 bundle
npm test         # 构建 + 单元测试 + 产物冒烟
```

真实网关端到端测试(未设置密钥时自动跳过):

```bash
GPT_LOAD_API_KEY=gl-... npm test
```

---

## License

MIT

Install

dsh plugin --profile web add github:wesleyel/dsh-plugin-gpt-load

Profile: web

  • This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source