mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
feat: 优化默认提示词(HARD GATE约束) + 扩展prompt变量(Phase1+2)
Phase 1: 重写 DEFAULT_TASK_BLOCKS 全部6个任务的 role/format/rules - 统一应用 HARD GATE 约束段 + 常见错误负例 - compress/synopsis 增加自检清单 - 增强 JSON 稳定性约束 Phase 2: 扩展 prompt 内置变量 - 新建 st-context.js: 统一读取 ST 上下文 - 新增变量: charName/userName/charDescription/userPersona/currentTime - 更新 extractor/retriever/compressor/consolidator 共6处调用端 - 更新 BUILTIN_BLOCK_DEFINITIONS 帮助文案(多轮对话指引)
This commit is contained in:
45
st-context.js
Normal file
45
st-context.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// ST-BME: SillyTavern 上下文数据读取辅助
|
||||
// 为 prompt 变量扩展(Phase 2)提供统一的 ST 上下文数据接口
|
||||
|
||||
import { getContext } from "../../../extensions.js";
|
||||
|
||||
/**
|
||||
* 从 SillyTavern 的 getContext() 提取当前上下文数据,
|
||||
* 返回的字段可直接展开传入 buildTaskPrompt 的 context 参数,
|
||||
* 用户在自定义 prompt 块中可通过 {{key}} 引用。
|
||||
*
|
||||
* @returns {object} 上下文字段映射
|
||||
*/
|
||||
export function getSTContextForPrompt() {
|
||||
try {
|
||||
const ctx = getContext?.() || {};
|
||||
const charId = ctx.characterId;
|
||||
const char =
|
||||
ctx.characters?.[Number(charId)] ||
|
||||
ctx.characters?.[charId] ||
|
||||
null;
|
||||
|
||||
return {
|
||||
userPersona:
|
||||
ctx.powerUserSettings?.persona_description ||
|
||||
ctx.name1_description ||
|
||||
"",
|
||||
charDescription:
|
||||
char?.description ||
|
||||
char?.data?.description ||
|
||||
"",
|
||||
charName: ctx.name2 || "",
|
||||
userName: ctx.name1 || "",
|
||||
currentTime: new Date().toLocaleString("zh-CN"),
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn("[ST-BME] getSTContextForPrompt 失败:", e);
|
||||
return {
|
||||
userPersona: "",
|
||||
charDescription: "",
|
||||
charName: "",
|
||||
userName: "",
|
||||
currentTime: new Date().toLocaleString("zh-CN"),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user