dsh-novel-writer 2.0.1 → 2.0.2
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/lib/index.js +6 -2
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1643,10 +1643,11 @@ function registerNovelStyleCheck(ctx, config) {
|
|
|
1643
1643
|
if (!allTexts[i]) continue;
|
|
1644
1644
|
for (const p of embedding.chunkText(allTexts[i])) allChunks.push({ ...p, id: String(i) + "|" + p.id });
|
|
1645
1645
|
}
|
|
1646
|
-
|
|
1646
|
+
const styleCacheKey = book + "__style_" + String(chapterArg).replace(/[\\/:*?"<>|]/g, "_");
|
|
1647
|
+
let index = embedding.loadIndex(root, styleCacheKey);
|
|
1647
1648
|
if (!index || index.length === 0) {
|
|
1648
1649
|
index = await embedding.embedMany(allChunks);
|
|
1649
|
-
embedding.saveIndex(root,
|
|
1650
|
+
embedding.saveIndex(root, styleCacheKey, index);
|
|
1650
1651
|
}
|
|
1651
1652
|
// 目标章段落向量 vs 其他章段落向量,平均余弦作为语义风格相似度
|
|
1652
1653
|
const targetChunks = allChunks.filter((ch) => ch.id.startsWith("0|"));
|
|
@@ -1664,6 +1665,9 @@ function registerNovelStyleCheck(ctx, config) {
|
|
|
1664
1665
|
note: semSim >= 0.55 ? "语义风格高度一致" : semSim >= 0.45 ? "语义风格中等一致" : "语义风格存在差异,注意写法口吻",
|
|
1665
1666
|
enabled: true
|
|
1666
1667
|
};
|
|
1668
|
+
} else {
|
|
1669
|
+
// v2.0.0 修复:样本不足时也返回对象(schema 要求 semantic 为 object)
|
|
1670
|
+
semantic = { enabled: false, note: "语义对比样本不足(目标章或基准章为空)" };
|
|
1667
1671
|
}
|
|
1668
1672
|
} catch (e) { semantic = { enabled: false, note: "语义对比失败:" + String(e).slice(0, 80) }; }
|
|
1669
1673
|
} else {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-novel-writer",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "小说写作助手插件(v2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "小说写作助手插件(v2.0.2):本地语义嵌入(bge-small-zh ONNX,0 token)——语义检索/语义风格对比/情感量化/世界观题材流派/语用审查,14 工具全 UI 开关",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|