预设兼容:按真实抓包对齐装配与包装层,补上声明式工具与预设正则。
- 装配只认 prompt_order.enabled;squash_system_messages 只合并相邻 system(新增 system 档,连接符按酒馆用单换行)
- 包装层:new_chat_prompt、示例对话(new_example_chat_prompt + <START> 切段 + name)、角色卡三块与 personality_format/scenario_format、{{user}}/{{char}} 取值、任务契约并进预设条目
- 工具协议:按 ToolBindings / 伪工具协议数据声明真 tools(presetToolPolicy=preset),工具描述用到的条目不再重复作为消息发出
- 正则:promptOnly 作用于对话历史(含 depth 过滤)、写入时脚本改写回复;{{//}} 注释按配平扫描
- tools/st-request-diff:真假上游抓包对比工具、三份预设的机制结论与实测报告
This commit is contained in:
+28
-13
@@ -6,17 +6,22 @@ import type {
|
||||
} from "../types/preset.js";
|
||||
|
||||
/** 酒馆角色卡 / WI marker:导入后保留位置;personaDescription 由当前用户角色填。 */
|
||||
export const ST_UNFILLED_MARKERS = new Set([
|
||||
"worldInfoBefore",
|
||||
"charDescription",
|
||||
"charPersonality",
|
||||
"scenario",
|
||||
"worldInfoAfter",
|
||||
"dialogueExamples",
|
||||
]);
|
||||
/** 酒馆的 worldInfoBefore / worldInfoAfter 现在由 pack 填,集合留空(保留判定入口)。 */
|
||||
export const ST_UNFILLED_MARKERS = new Set<string>([]);
|
||||
|
||||
export const WORLD_INFO_BEFORE_MARKER = "worldInfoBefore";
|
||||
export const WORLD_INFO_AFTER_MARKER = "worldInfoAfter";
|
||||
|
||||
export const PERSONA_DESCRIPTION_MARKER = "personaDescription";
|
||||
|
||||
/** 酒馆示例对话洞:new_example_chat_prompt + mes_example 切出来的多段。 */
|
||||
export const DIALOGUE_EXAMPLES_MARKER = "dialogueExamples";
|
||||
|
||||
/** 角色卡三块:由直聊槽位填,不再当"酒馆未填洞"跳过。 */
|
||||
export const CHAR_DESCRIPTION_MARKER = "charDescription";
|
||||
export const CHAR_PERSONALITY_MARKER = "charPersonality";
|
||||
export const SCENARIO_MARKER = "scenario";
|
||||
|
||||
export const CHAT_HISTORY_MARKER = "chatHistory";
|
||||
export const WORLD_BOOK_BEFORE = "worldBookBefore";
|
||||
export const WORLD_BOOK_AFTER = "worldBookAfter";
|
||||
@@ -89,20 +94,30 @@ export function applyExtendedMarkers(preset: PresetPackage): PresetPackage {
|
||||
const histIndex = rawOrder.findIndex(
|
||||
(item) => item.promptId === CHAT_HISTORY_MARKER,
|
||||
);
|
||||
|
||||
// 预设自带酒馆的 worldInfoBefore / worldInfoAfter(并启用)时,不插自有的世界书洞:
|
||||
// 内容直接填进预设那两条,位置上才对得上酒馆。
|
||||
const hasStBefore = rawOrder.some(
|
||||
(item) => item.promptId === WORLD_INFO_BEFORE_MARKER && item.enabled,
|
||||
);
|
||||
const hasStAfter = rawOrder.some(
|
||||
(item) => item.promptId === WORLD_INFO_AFTER_MARKER && item.enabled,
|
||||
);
|
||||
const inserted = (id: string): PresetPromptOrderItem => ({
|
||||
promptId: id,
|
||||
enabled: true,
|
||||
orderIndex: 0,
|
||||
});
|
||||
|
||||
const beforeMarkers = hasStBefore ? [] : [inserted(WORLD_BOOK_BEFORE)];
|
||||
const afterMarkers = hasStAfter ? [] : [inserted(WORLD_BOOK_AFTER)];
|
||||
|
||||
let next: PresetPromptOrderItem[];
|
||||
if (histIndex < 0) {
|
||||
next = reindex([
|
||||
...rawOrder,
|
||||
inserted(WORLD_BOOK_BEFORE),
|
||||
...beforeMarkers,
|
||||
inserted(CHAT_HISTORY_MARKER),
|
||||
inserted(WORLD_BOOK_AFTER),
|
||||
...afterMarkers,
|
||||
inserted(CURRENT_TURN),
|
||||
inserted(POST_TURN),
|
||||
]);
|
||||
@@ -112,9 +127,9 @@ export function applyExtendedMarkers(preset: PresetPackage): PresetPackage {
|
||||
const after = rawOrder.slice(histIndex + 1);
|
||||
next = reindex([
|
||||
...before,
|
||||
inserted(WORLD_BOOK_BEFORE),
|
||||
...beforeMarkers,
|
||||
history,
|
||||
inserted(WORLD_BOOK_AFTER),
|
||||
...afterMarkers,
|
||||
inserted(CURRENT_TURN),
|
||||
...after,
|
||||
inserted(POST_TURN),
|
||||
|
||||
Reference in New Issue
Block a user