@zaofan/dsh-qqbot 1.4.1 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/README_EN.md +60 -0
- package/client/qqbot-settings.js +429 -4
- package/dist/channel-tools.d.ts +15 -0
- package/dist/channel-tools.d.ts.map +1 -1
- package/dist/channel-tools.js +59 -1
- package/dist/channel-tools.js.map +1 -1
- package/dist/config.d.ts +32 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -1
- package/dist/config.js.map +1 -1
- package/dist/features/image-path-cache.d.ts +23 -0
- package/dist/features/image-path-cache.d.ts.map +1 -0
- package/dist/features/image-path-cache.js +38 -0
- package/dist/features/image-path-cache.js.map +1 -0
- package/dist/features/image-url-ledger.d.ts +19 -0
- package/dist/features/image-url-ledger.d.ts.map +1 -0
- package/dist/features/image-url-ledger.js +133 -0
- package/dist/features/image-url-ledger.js.map +1 -0
- package/dist/features/local-embed.d.ts +43 -0
- package/dist/features/local-embed.d.ts.map +1 -0
- package/dist/features/local-embed.js +143 -0
- package/dist/features/local-embed.js.map +1 -0
- package/dist/features/sticker-store.d.ts +48 -2
- package/dist/features/sticker-store.d.ts.map +1 -1
- package/dist/features/sticker-store.js +156 -1
- package/dist/features/sticker-store.js.map +1 -1
- package/dist/features/value-sample.d.ts +25 -0
- package/dist/features/value-sample.d.ts.map +1 -0
- package/dist/features/value-sample.js +122 -0
- package/dist/features/value-sample.js.map +1 -0
- package/dist/features/value-score.d.ts +36 -0
- package/dist/features/value-score.d.ts.map +1 -0
- package/dist/features/value-score.js +122 -0
- package/dist/features/value-score.js.map +1 -0
- package/dist/gateway/bootstrap.d.ts.map +1 -1
- package/dist/gateway/bootstrap.js +4 -0
- package/dist/gateway/bootstrap.js.map +1 -1
- package/dist/gateway/debounce.d.ts.map +1 -1
- package/dist/gateway/debounce.js +16 -5
- package/dist/gateway/debounce.js.map +1 -1
- package/dist/gateway/middleware-setup.d.ts.map +1 -1
- package/dist/gateway/middleware-setup.js +12 -1
- package/dist/gateway/middleware-setup.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware/sticker-capture.d.ts +8 -2
- package/dist/middleware/sticker-capture.d.ts.map +1 -1
- package/dist/middleware/sticker-capture.js +63 -45
- package/dist/middleware/sticker-capture.js.map +1 -1
- package/dist/model/model-resolver.js +12 -6
- package/dist/model/model-resolver.js.map +1 -1
- package/dist/transport/attachment.d.ts +5 -1
- package/dist/transport/attachment.d.ts.map +1 -1
- package/dist/transport/attachment.js +16 -5
- package/dist/transport/attachment.js.map +1 -1
- package/dist/transport/inbound.d.ts.map +1 -1
- package/dist/transport/inbound.js +351 -9
- package/dist/transport/inbound.js.map +1 -1
- package/dist/transport/inject-rules.d.ts.map +1 -1
- package/dist/transport/inject-rules.js +3 -1
- package/dist/transport/inject-rules.js.map +1 -1
- package/package.json +3 -2
- package/scripts/download-model.mjs +112 -0
- package/settings-host.js +337 -5
package/README.md
CHANGED
|
@@ -253,6 +253,75 @@ npx @deepseek-ai/dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
|
|
|
253
253
|
|
|
254
254
|
**配置项**(Web 面板 ⑥ 可改, 见下表 `groupAdmin.*`)
|
|
255
255
|
|
|
256
|
+
## 🧠 智能回复(本地小模型 · 可选,省 token)(v1.4.5+)
|
|
257
|
+
|
|
258
|
+
让插件先用一个**跑在本机的小模型**给群消息打分(「价值评分」):分数低于门槛、又**没被 @** 的闲聊
|
|
259
|
+
**直接不唤醒 AI** → 那一轮 token 就省下来了;被 @ 的永远放行,**带图的消息一律放行**(群友发图多半是给她看的)。
|
|
260
|
+
|
|
261
|
+
- **模型**:`bge-small-zh-v1.5`(中文专训,ONNX 量化版 **≈ 23MB**,CPU 毫秒级,**零 token、完全离线**,不上传任何内容)
|
|
262
|
+
- **位置**:`{DSH_HOME | ~/.dsh}/models/bge-small-zh/`(用户级,跨工作区共用一份;也可在配置里指别的目录)
|
|
263
|
+
- **缺了也不影响使用**:检测不到模型就**自动静默关闭**评分,插件照常跑(只是不再省 token)
|
|
264
|
+
|
|
265
|
+
### ① 一条命令下载(推荐)
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
node scripts/download-model.mjs # 源码分发(在插件仓库根目录跑)
|
|
269
|
+
node node_modules/@zaofan/dsh-qqbot/scripts/download-model.mjs # npm 装的插件(npm 目录内)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
默认**优先走国内镜像** `hf-mirror.com`(失败自动换官方源),下载完会校验体积并打印后续步骤。可选参数:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
node scripts/download-model.mjs --dir "D:\models\bge-small-zh" # 换目录(填进插件配置 localModel.modelDir)
|
|
276
|
+
node scripts/download-model.mjs --source hf # 强制官方源
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### ② 手动下载(就三个文件)
|
|
280
|
+
|
|
281
|
+
把 `<源>` 换成 `https://hf-mirror.com` 或 `https://huggingface.co`,文件放到 `~/.dsh/models/bge-small-zh/`:
|
|
282
|
+
|
|
283
|
+
| 下载地址 | 存放位置 | 体积参考 |
|
|
284
|
+
|---|---|---|
|
|
285
|
+
| `<源>/Xenova/bge-small-zh-v1.5/resolve/main/onnx/model_quantized.onnx` | `bge-small-zh/onnx/model_quantized.onnx` | ≈ 23MB |
|
|
286
|
+
| `<源>/Xenova/bge-small-zh-v1.5/resolve/main/tokenizer.json` | `bge-small-zh/tokenizer.json` | ≈ 430KB |
|
|
287
|
+
| `<源>/Xenova/bge-small-zh-v1.5/resolve/main/config.json` | `bge-small-zh/config.json` | < 1KB |
|
|
288
|
+
|
|
289
|
+
Windows PowerShell 例子:
|
|
290
|
+
|
|
291
|
+
```powershell
|
|
292
|
+
$dir = "$env:USERPROFILE\.dsh\models\bge-small-zh"
|
|
293
|
+
$base = "https://hf-mirror.com/Xenova/bge-small-zh-v1.5/resolve/main"
|
|
294
|
+
New-Item -ItemType Directory -Force "$dir\onnx" | Out-Null
|
|
295
|
+
Invoke-WebRequest "$base/onnx/model_quantized.onnx" -OutFile "$dir\onnx\model_quantized.onnx"
|
|
296
|
+
Invoke-WebRequest "$base/tokenizer.json" -OutFile "$dir\tokenizer.json"
|
|
297
|
+
Invoke-WebRequest "$base/config.json" -OutFile "$dir\config.json"
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### ③ 交给 AI 做(把下面这段直接粘给你的 AI / dsh 里的她)
|
|
301
|
+
|
|
302
|
+
```text
|
|
303
|
+
请帮我在本机装好 dsh 的 qqbot 插件要用的本地小模型(离线、不上传内容):
|
|
304
|
+
1. 下载 BAAI/bge-small-zh-v1.5 的三个文件到 `~/.dsh/models/bge-small-zh/`:
|
|
305
|
+
onnx/model_quantized.onnx(≈23MB)、tokenizer.json、config.json;
|
|
306
|
+
国内优先用 https://hf-mirror.com,失败再试 https://huggingface.co。
|
|
307
|
+
2. 目录结构必须是:<模型目录>/onnx/model_quantized.onnx、<模型目录>/tokenizer.json、<模型目录>/config.json
|
|
308
|
+
3. 下完自己校验:model_quantized.onnx ≥ 20MB、tokenizer.json ≥ 300KB;
|
|
309
|
+
也可以直接跑插件仓库里的一键脚本:`node scripts/download-model.mjs`
|
|
310
|
+
4. 最后告诉我:插件设置页「本地小模型」这一项该填什么、以及三个评分模式 off / log / block 分别什么行为。
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 评分模式怎么选
|
|
314
|
+
|
|
315
|
+
| 模式 | 行为 | 建议 |
|
|
316
|
+
|---|---|---|
|
|
317
|
+
| `off` | 完全不评分,所有消息照常唤醒 | 不想掺和 |
|
|
318
|
+
| `log` | **只记分,不拦** | **观察期**:先跑几天,在面板「最近评分」看分准不准 |
|
|
319
|
+
| `block` | 低于门槛(默认 `0.5`)**不唤醒** | 正式使用、省 token |
|
|
320
|
+
|
|
321
|
+
- **会话级覆盖**:dock「⚙ 单会话设置」里可以**按群单独设**模式 / 门槛 / 开关(存 `settings.yaml` 的 `localModel.overrides`),**保存即时生效,无需重启**(v1.4.5 起)。
|
|
322
|
+
- **拦截边界**:被 @ 的永远放行;带图一律放行;**只有被拦在唤醒之前**(没花 token)的那次才会**回滚**本群的回复冷却 —— 冷却本来就是用来省 token 的,token 花了就不算白花。
|
|
323
|
+
- **评分记录**:`{dataRoot}/.qqbot/value-scores.jsonl`,一行一条,字段 `score / worth / gate / min / conf / mention / img / lib / agg / top`。面板能直读,也可以让 AI 读它来维护样例库(`{dataRoot}/.qqbot/value-samples.jsonl`:`{"m":"消息文本","y":1|0}`,y=1 表示"她会想接话")。
|
|
324
|
+
|
|
256
325
|
## 配置项
|
|
257
326
|
|
|
258
327
|
| 配置 | 类型 | 默认值 | 说明 |
|
package/README_EN.md
CHANGED
|
@@ -205,6 +205,66 @@ auto-cancelled when the agent is cancelled or dsh exits.
|
|
|
205
205
|
> Idea source: QQ-approval design of wang-22-code/dsh-qqbot-bridge (host dsh `approval/request`
|
|
206
206
|
> standard event — the same wiring used by official dsh-acp and the Web approval dialog).
|
|
207
207
|
|
|
208
|
+
## 🧠 Smart reply (local small model, optional — saves tokens) (v1.4.5+)
|
|
209
|
+
|
|
210
|
+
Let the plugin score incoming group messages **locally first** ("value scoring"): chatter that scores below the
|
|
211
|
+
threshold **and is not @-mentioning the bot** will **not wake the model at all** → those tokens are simply not spent.
|
|
212
|
+
Messages that @ the bot always pass; **messages with images always pass** (people usually send images *to* her).
|
|
213
|
+
|
|
214
|
+
- **Model**: `bge-small-zh-v1.5` (Chinese-tuned, quantized ONNX **≈ 23MB**, millisecond-level on CPU, **fully offline**, zero tokens, nothing is uploaded)
|
|
215
|
+
- **Location**: `{DSH_HOME | ~/.dsh}/models/bge-small-zh/` (user-level, shared across workspaces; a custom dir can be set in the config)
|
|
216
|
+
- **Missing model is fine**: scoring silently disables itself and the plugin keeps working (you just don't get the savings)
|
|
217
|
+
|
|
218
|
+
### ① One command (recommended)
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
node scripts/download-model.mjs # from the source checkout
|
|
222
|
+
node node_modules/@zaofan/dsh-qqbot/scripts/download-model.mjs # when installed via npm
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
It prefers the China mirror `hf-mirror.com` and falls back to the official host, verifies file sizes, and prints the next steps.
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
node scripts/download-model.mjs --dir "D:\models\bge-small-zh" # custom dir → put it in localModel.modelDir
|
|
229
|
+
node scripts/download-model.mjs --source hf # force the official host
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### ② Manual download (only three files)
|
|
233
|
+
|
|
234
|
+
Replace `<base>` with `https://hf-mirror.com` or `https://huggingface.co`, and put the files under `~/.dsh/models/bge-small-zh/`:
|
|
235
|
+
|
|
236
|
+
| Download | Put at | Size |
|
|
237
|
+
|---|---|---|
|
|
238
|
+
| `<base>/Xenova/bge-small-zh-v1.5/resolve/main/onnx/model_quantized.onnx` | `bge-small-zh/onnx/model_quantized.onnx` | ≈ 23MB |
|
|
239
|
+
| `<base>/Xenova/bge-small-zh-v1.5/resolve/main/tokenizer.json` | `bge-small-zh/tokenizer.json` | ≈ 430KB |
|
|
240
|
+
| `<base>/Xenova/bge-small-zh-v1.5/resolve/main/config.json` | `bge-small-zh/config.json` | < 1KB |
|
|
241
|
+
|
|
242
|
+
### ③ Let your AI do it (paste this to the AI / to her)
|
|
243
|
+
|
|
244
|
+
```text
|
|
245
|
+
Please install the local small model used by the dsh qqbot plugin on this machine (offline; nothing is uploaded):
|
|
246
|
+
1. Download three files from BAAI/bge-small-zh-v1.5 into `~/.dsh/models/bge-small-zh/`:
|
|
247
|
+
onnx/model_quantized.onnx (~23MB), tokenizer.json, config.json.
|
|
248
|
+
Prefer https://hf-mirror.com, fall back to https://huggingface.co.
|
|
249
|
+
2. The layout must be: <model dir>/onnx/model_quantized.onnx, <model dir>/tokenizer.json, <model dir>/config.json
|
|
250
|
+
3. Verify afterwards: model_quantized.onnx ≥ 20MB, tokenizer.json ≥ 300KB.
|
|
251
|
+
The plugin repo ships a one-shot script: `node scripts/download-model.mjs`
|
|
252
|
+
4. Finally tell me which setting to fill in the plugin settings page, and what the three
|
|
253
|
+
scoring modes off / log / block actually do.
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Which mode to pick
|
|
257
|
+
|
|
258
|
+
| Mode | Behaviour | Suggested |
|
|
259
|
+
|---|---|---|
|
|
260
|
+
| `off` | no scoring at all, everything wakes her | not interested |
|
|
261
|
+
| `log` | **records scores but never blocks** | **observation period** — watch the panel for a few days |
|
|
262
|
+
| `block` | below the threshold (default `0.5`) **does not wake** | production use, saves tokens |
|
|
263
|
+
|
|
264
|
+
- **Per-session override**: the dock's "⚙ Single-session settings" can set mode / threshold / toggle **per group** (stored in `localModel.overrides` in `settings.yaml`), **applied live, no restart needed** (since v1.4.5).
|
|
265
|
+
- **Boundaries**: @-mentions always pass; messages with images always pass; only a dispatch that was blocked **before waking her** (no tokens spent) rolls the group reply-cooldown back — the cooldown exists to save tokens, so already-spent tokens still count.
|
|
266
|
+
- **Score log**: `{dataRoot}/.qqbot/value-scores.jsonl`, one JSON per line with `score / worth / gate / min / conf / mention / img / lib / agg / top`. The panel reads it directly, and the AI can read it to maintain the sample library (`{dataRoot}/.qqbot/value-samples.jsonl`, `{"m":"text","y":1|0}` — y=1 means "she would want to reply").
|
|
267
|
+
|
|
208
268
|
## Configuration
|
|
209
269
|
|
|
210
270
|
| Config | Type | Default | Description |
|