mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
Fix task regex final input pipeline
This commit is contained in:
@@ -254,7 +254,8 @@ try {
|
||||
|
||||
assert.match(promptBuild.systemPrompt, /GOOD_RECENT/);
|
||||
assert.match(JSON.stringify(promptBuild.executionMessages), /GOOD_CANDIDATE/);
|
||||
assert.match(promptBuild.systemPrompt, /FINAL_GOOD/);
|
||||
assert.match(promptBuild.systemPrompt, /FINAL_BAD/);
|
||||
assert.doesNotMatch(promptBuild.systemPrompt, /FINAL_GOOD/);
|
||||
assert.equal(
|
||||
promptBuild.debug.mvu.sanitizedFields.some((entry) => entry.name === "userMessage"),
|
||||
true,
|
||||
@@ -454,6 +455,8 @@ try {
|
||||
|
||||
const payload = buildTaskLlmPayload(promptBuild, "unused fallback");
|
||||
assert.equal(payload.systemPrompt, "");
|
||||
assert.match(JSON.stringify(payload.promptMessages), /FINAL_BAD/);
|
||||
assert.doesNotMatch(JSON.stringify(payload.promptMessages), /FINAL_GOOD/);
|
||||
const result = await llm.callLLMForJSON({
|
||||
systemPrompt: payload.systemPrompt,
|
||||
userPrompt: payload.userPrompt,
|
||||
@@ -466,6 +469,8 @@ try {
|
||||
|
||||
assert.deepEqual(result, { ok: true });
|
||||
assert.equal(capturedBodies.length, 1);
|
||||
assert.match(JSON.stringify(capturedBodies[0].messages), /FINAL_GOOD/);
|
||||
assert.doesNotMatch(JSON.stringify(capturedBodies[0].messages), /FINAL_BAD/);
|
||||
assert.doesNotMatch(
|
||||
JSON.stringify(capturedBodies[0].messages),
|
||||
/status_current_variable|updatevariable|StatusPlaceHolderImpl|stat_data|display_data|delta_data|get_message_variable/i,
|
||||
@@ -478,6 +483,18 @@ try {
|
||||
|
||||
assert.ok(runtimePromptBuild);
|
||||
assert.ok(runtimeLlmRequest);
|
||||
assert.match(JSON.stringify(runtimeLlmRequest.messages), /FINAL_GOOD/);
|
||||
assert.equal(runtimeLlmRequest.requestCleaning?.applied, true);
|
||||
assert.equal(
|
||||
runtimeLlmRequest.requestCleaning?.stages?.length > 0,
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
runtimeLlmRequest.requestCleaning?.stages?.every(
|
||||
(entry) => entry.stage === "input.finalPrompt",
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
JSON.stringify(runtimePromptBuild.executionMessages),
|
||||
/status_current_variable|updatevariable|StatusPlaceHolderImpl|stat_data|display_data|delta_data|get_message_variable/i,
|
||||
|
||||
@@ -365,6 +365,79 @@ try {
|
||||
assert.equal(exactStageResult, "JSON");
|
||||
assert.deepEqual(exactStageDebug.entries[0].appliedRules, []);
|
||||
|
||||
const legacyStageCompatibilitySettings = {
|
||||
taskProfilesVersion: 1,
|
||||
taskProfiles: {
|
||||
extract: {
|
||||
activeProfileId: "legacy-stage-compat",
|
||||
profiles: [
|
||||
{
|
||||
id: "legacy-stage-compat",
|
||||
taskType: "extract",
|
||||
regex: {
|
||||
enabled: true,
|
||||
inheritStRegex: false,
|
||||
sources: {
|
||||
global: false,
|
||||
preset: false,
|
||||
character: false,
|
||||
},
|
||||
stages: {
|
||||
input: true,
|
||||
output: true,
|
||||
"input.userMessage": false,
|
||||
"input.recentMessages": false,
|
||||
"input.candidateText": false,
|
||||
"input.finalPrompt": false,
|
||||
"output.rawResponse": false,
|
||||
"output.beforeParse": false,
|
||||
},
|
||||
localRules: [
|
||||
createRule("legacy-input-user", "/Alpha/g", "A1"),
|
||||
createRule("legacy-output-raw", "/Omega/g", "O1", {
|
||||
source: {
|
||||
user_input: false,
|
||||
ai_output: true,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const legacyStageInputDebug = { entries: [] };
|
||||
const legacyStageInputResult = applyTaskRegex(
|
||||
legacyStageCompatibilitySettings,
|
||||
"extract",
|
||||
"input.userMessage",
|
||||
"Alpha",
|
||||
legacyStageInputDebug,
|
||||
"user",
|
||||
);
|
||||
assert.equal(legacyStageInputResult, "A1");
|
||||
assert.deepEqual(
|
||||
legacyStageInputDebug.entries[0].appliedRules.map((item) => item.id),
|
||||
["legacy-input-user"],
|
||||
);
|
||||
|
||||
const legacyStageOutputDebug = { entries: [] };
|
||||
const legacyStageOutputResult = applyTaskRegex(
|
||||
legacyStageCompatibilitySettings,
|
||||
"extract",
|
||||
"output.rawResponse",
|
||||
"Omega",
|
||||
legacyStageOutputDebug,
|
||||
"assistant",
|
||||
);
|
||||
assert.equal(legacyStageOutputResult, "O1");
|
||||
assert.deepEqual(
|
||||
legacyStageOutputDebug.entries[0].appliedRules.map((item) => item.id),
|
||||
["legacy-output-raw"],
|
||||
);
|
||||
|
||||
console.log("task-regex tests passed");
|
||||
} finally {
|
||||
if (originalSillyTavern === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user