dsh-plugin-om 0.0.11 → 0.0.12
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 +6 -5
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,17 +85,16 @@ dsh的"预设"分为两层,`dsh web`等同于`dsh --profile web`,调用的
|
|
|
85
85
|
|
|
86
86
|
### 依赖策略
|
|
87
87
|
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
- 模型二进制:量化 ONNX 约 113MB,超过 GitHub 单文件 100MB 限制,**不进入 git 仓库,也不随 npm 包分发**(`package.json` 的 `files` 以 `!models/*/onnx/*.onnx` 排除,见 `tests/package-pack.test.ts`)。改为**运行时按需下载**:仅当配置键 `semanticRecallEnabled` 启用且共享目录 `$DSH_HOME/plugin-data/dsh-plugin-om/models/<id>/onnx/model_quantized.onnx` 缺失时,插件 apply 后台自动从 HuggingFace([Xenova 转换仓库](https://huggingface.co/Xenova/paraphrase-multilingual-MiniLM-L12-v2))下载到该共享目录(不阻塞;下载开始/结束经 console 与插件日志输出,失败仅记日志并附带设置 `HF_ENDPOINT=https://hf-mirror.com` 的镜像建议,下次调用自动重试;未就绪时 `recall-semantic` 工具返回文案告知模型);共享目录跨插件版本复用,升级/重装插件不重复下载,随包小文件(config/tokenizer 等)缺失时自动从插件包复制补齐(离线可用);本地开发也可用 `pnpm run download:model` 手动预下载到同一共享目录(已存在则跳过,`--force` 强制重下);直连 `huggingface.co` 受限时设置环境变量 `HF_ENDPOINT=https://hf-mirror.com` 走镜像
|
|
88
|
+
- dsh宿主提供的依赖,直接复用即可,如 cordis / dsh-tools / zod 等
|
|
89
|
+
- 向量模型模型二进制:量化 ONNX 约 113MB,启用语义召回时下载,位置`$DSH_HOME/plugin-data/dsh-plugin-om/models/<id>/onnx/model_quantized.onnx`。下载失败可以设置`HF_ENDPOINT=https://hf-mirror.com`
|
|
91
90
|
|
|
92
91
|
## 插件配置项
|
|
93
92
|
|
|
94
93
|
| 键 | 默认 | 含义 |
|
|
95
94
|
| ----------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
-
| `thresholdRatio` | `0.
|
|
95
|
+
| `thresholdRatio` | `0.1` | 观察阈值:未压缩消息 ≥ 窗口 × 该比例触发压缩 |
|
|
97
96
|
| `historyMergeRatio` | `0.2` | 反思阈值:摘要 ≥ 窗口 × 该比例触发精简合并 |
|
|
98
|
-
| `compressMaxTokens` | `
|
|
97
|
+
| `compressMaxTokens` | `10000` | 单次摘要(观察/反思调用)生成上限 |
|
|
99
98
|
| `tailMessageCount` | `10` | 尾部保留的不压缩消息条数(不压缩、不被替换、不进摘要日志) |
|
|
100
99
|
| `modelDir` | 共享目录 | recall-semantic 嵌入模型目录(默认 `$DSH_HOME/plugin-data/dsh-plugin-om/models/<id>`,跨插件版本共享;小文件随包分发并在缺失时自动补齐,onnx 缺失且启用语义召回时运行时自动下载到该目录;可指向自定义目录) |
|
|
101
100
|
| `summaryMode` | `fork` | 摘要模式:`fork`(缺省)/ `new` / `disable`(关闭自动压缩);非法值在插件加载时报错(见[摘要模式](#摘要模式)) |
|
|
@@ -103,6 +102,8 @@ dsh的"预设"分为两层,`dsh web`等同于`dsh --profile web`,调用的
|
|
|
103
102
|
| `recallEnabled` | `true` | 是否注册 `recall` 工具(`false` 时禁用,不注册) |
|
|
104
103
|
| `semanticRecallEnabled` | `true` | 是否注册 `recall-semantic` 工具(`false` 时禁用,不注册、不触发模型下载) |
|
|
105
104
|
|
|
105
|
+
> 不建议将thresholdRatio设置的过高,越早OM收益越高,且当前的机制需要模型对消息计数,过多的消息会导致历史混乱
|
|
106
|
+
|
|
106
107
|
### 摘要模式
|
|
107
108
|
|
|
108
109
|
摘要调用由配置键 `summaryMode` 控制:
|
package/dist/index.mjs
CHANGED
|
@@ -1196,9 +1196,9 @@ function cosineSimilarity(a, b) {
|
|
|
1196
1196
|
*/
|
|
1197
1197
|
/** 默认配置(冻结对象,resolveConfig 合并的基底;debug 缺省值在解析时按 NODE_ENV 判定)。 */
|
|
1198
1198
|
const DEFAULT_CONFIG = Object.freeze({
|
|
1199
|
-
thresholdRatio: .
|
|
1199
|
+
thresholdRatio: .1,
|
|
1200
1200
|
historyMergeRatio: .2,
|
|
1201
|
-
compressMaxTokens:
|
|
1201
|
+
compressMaxTokens: 1e4,
|
|
1202
1202
|
tailMessageCount: 10,
|
|
1203
1203
|
summaryMode: "fork",
|
|
1204
1204
|
debug: false,
|