Adjust summary trigger role settings
This commit is contained in:
@@ -27,7 +27,8 @@ export function getSummaryPanelConfig() {
|
|||||||
trigger: {
|
trigger: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
interval: 20,
|
interval: 20,
|
||||||
timing: 'after_ai',
|
timing: 'before_user',
|
||||||
|
role: 'system',
|
||||||
useStream: true,
|
useStream: true,
|
||||||
maxPerRun: 100,
|
maxPerRun: 100,
|
||||||
wrapperHead: '',
|
wrapperHead: '',
|
||||||
|
|||||||
@@ -52,8 +52,6 @@
|
|||||||
openai: { url: 'https://api.openai.com', needKey: true, canFetch: true, needManualModel: false },
|
openai: { url: 'https://api.openai.com', needKey: true, canFetch: true, needManualModel: false },
|
||||||
google: { url: 'https://generativelanguage.googleapis.com', needKey: true, canFetch: false, needManualModel: true },
|
google: { url: 'https://generativelanguage.googleapis.com', needKey: true, canFetch: false, needManualModel: true },
|
||||||
claude: { url: 'https://api.anthropic.com', needKey: true, canFetch: false, needManualModel: true },
|
claude: { url: 'https://api.anthropic.com', needKey: true, canFetch: false, needManualModel: true },
|
||||||
deepseek: { url: 'https://api.deepseek.com', needKey: true, canFetch: true, needManualModel: false },
|
|
||||||
cohere: { url: 'https://api.cohere.ai', needKey: true, canFetch: false, needManualModel: true },
|
|
||||||
custom: { url: '', needKey: true, canFetch: true, needManualModel: false }
|
custom: { url: '', needKey: true, canFetch: true, needManualModel: false }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,7 +112,7 @@
|
|||||||
const config = {
|
const config = {
|
||||||
api: { provider: 'st', url: '', key: '', model: '', modelCache: [] },
|
api: { provider: 'st', url: '', key: '', model: '', modelCache: [] },
|
||||||
gen: { temperature: null, top_p: null, top_k: null, presence_penalty: null, frequency_penalty: null },
|
gen: { temperature: null, top_p: null, top_k: null, presence_penalty: null, frequency_penalty: null },
|
||||||
trigger: { enabled: false, interval: 20, timing: 'after_ai', useStream: true, maxPerRun: 100, wrapperHead: '', wrapperTail: '', forceInsertAtEnd: false },
|
trigger: { enabled: false, interval: 20, timing: 'before_user', role: 'system', useStream: true, maxPerRun: 100, wrapperHead: '', wrapperTail: '', forceInsertAtEnd: false },
|
||||||
vector: { enabled: false, engine: 'online', local: { modelId: 'bge-small-zh' }, online: { provider: 'siliconflow', url: '', key: '', model: '' } }
|
vector: { enabled: false, engine: 'online', local: { modelId: 'bge-small-zh' }, online: { provider: 'siliconflow', url: '', key: '', model: '' } }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -526,6 +524,7 @@
|
|||||||
$('trigger-enabled').checked = config.trigger.enabled;
|
$('trigger-enabled').checked = config.trigger.enabled;
|
||||||
$('trigger-interval').value = config.trigger.interval;
|
$('trigger-interval').value = config.trigger.interval;
|
||||||
$('trigger-timing').value = config.trigger.timing;
|
$('trigger-timing').value = config.trigger.timing;
|
||||||
|
$('trigger-role').value = config.trigger.role || 'system';
|
||||||
$('trigger-stream').checked = config.trigger.useStream !== false;
|
$('trigger-stream').checked = config.trigger.useStream !== false;
|
||||||
$('trigger-max-per-run').value = config.trigger.maxPerRun || 100;
|
$('trigger-max-per-run').value = config.trigger.maxPerRun || 100;
|
||||||
$('trigger-wrapper-head').value = config.trigger.wrapperHead || '';
|
$('trigger-wrapper-head').value = config.trigger.wrapperHead || '';
|
||||||
@@ -574,6 +573,7 @@
|
|||||||
|
|
||||||
const timing = $('trigger-timing').value;
|
const timing = $('trigger-timing').value;
|
||||||
config.trigger.timing = timing;
|
config.trigger.timing = timing;
|
||||||
|
config.trigger.role = $('trigger-role').value || 'system';
|
||||||
config.trigger.enabled = timing === 'manual' ? false : $('trigger-enabled').checked;
|
config.trigger.enabled = timing === 'manual' ? false : $('trigger-enabled').checked;
|
||||||
config.trigger.interval = parseInt($('trigger-interval').value) || 20;
|
config.trigger.interval = parseInt($('trigger-interval').value) || 20;
|
||||||
config.trigger.useStream = $('trigger-stream').checked;
|
config.trigger.useStream = $('trigger-stream').checked;
|
||||||
|
|||||||
@@ -173,8 +173,6 @@
|
|||||||
<option value="openai">OpenAI 兼容</option>
|
<option value="openai">OpenAI 兼容</option>
|
||||||
<option value="google">Google (Gemini)</option>
|
<option value="google">Google (Gemini)</option>
|
||||||
<option value="claude">Claude (Anthropic)</option>
|
<option value="claude">Claude (Anthropic)</option>
|
||||||
<option value="deepseek">DeepSeek</option>
|
|
||||||
<option value="cohere">Cohere</option>
|
|
||||||
<option value="custom">自定义</option>
|
<option value="custom">自定义</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -243,6 +241,16 @@
|
|||||||
<!-- Trigger Settings -->
|
<!-- Trigger Settings -->
|
||||||
<div class="settings-section">
|
<div class="settings-section">
|
||||||
<div class="settings-section-title">总结设置</div>
|
<div class="settings-section-title">总结设置</div>
|
||||||
|
<div class="settings-row">
|
||||||
|
<div class="settings-field">
|
||||||
|
<label>注入角色</label>
|
||||||
|
<select id="trigger-role">
|
||||||
|
<option value="system">System</option>
|
||||||
|
<option value="user">User</option>
|
||||||
|
<option value="assistant">Assistant</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="settings-row">
|
<div class="settings-row">
|
||||||
<div class="settings-field">
|
<div class="settings-field">
|
||||||
<label>自动总结间隔(楼)</label>
|
<label>自动总结间隔(楼)</label>
|
||||||
@@ -252,7 +260,7 @@
|
|||||||
<label>触发时机</label>
|
<label>触发时机</label>
|
||||||
<select id="trigger-timing">
|
<select id="trigger-timing">
|
||||||
<option value="after_ai">AI 回复后</option>
|
<option value="after_ai">AI 回复后</option>
|
||||||
<option value="before_user">用户发送前</option>
|
<option value="before_user" selected>用户发送前</option>
|
||||||
<option value="manual">仅手动</option>
|
<option value="manual">仅手动</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -444,12 +452,13 @@
|
|||||||
<!-- 向量导入导出 -->
|
<!-- 向量导入导出 -->
|
||||||
<div class="vector-io-section" style="border-top:1px solid var(--bdr);padding-top:16px;margin-top:16px">
|
<div class="vector-io-section" style="border-top:1px solid var(--bdr);padding-top:16px;margin-top:16px">
|
||||||
<div class="settings-row">
|
<div class="settings-row">
|
||||||
<div class="settings-field full">
|
<div class="settings-field full">
|
||||||
<label>向量迁移(跨设备 / 防清缓存)</label>
|
<label>向量迁移(跨设备 / 防清缓存)</label>
|
||||||
<div class="settings-btn-row" id="vector-io-row" style="margin-top:8px">
|
<div class="settings-hint" style="margin-bottom:8px">导出/导入均为 zip 格式,勿解压</div>
|
||||||
<button class="btn btn-sm" id="btn-export-vectors">导出向量</button>
|
<div class="settings-btn-row" id="vector-io-row" style="margin-top:8px">
|
||||||
<button class="btn btn-sm" id="btn-import-vectors">导入向量</button>
|
<button class="btn btn-sm" id="btn-export-vectors">导出向量</button>
|
||||||
</div>
|
<button class="btn btn-sm" id="btn-import-vectors">导入向量</button>
|
||||||
|
</div>
|
||||||
<div class="settings-hint" id="vector-io-status"></div>
|
<div class="settings-hint" id="vector-io-status"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -117,6 +117,13 @@ const VECTOR_WARNING_COOLDOWN_MS = 120000; // 2分钟内不重复提醒
|
|||||||
|
|
||||||
const EXT_PROMPT_KEY = "LittleWhiteBox_StorySummary";
|
const EXT_PROMPT_KEY = "LittleWhiteBox_StorySummary";
|
||||||
|
|
||||||
|
// role 映射
|
||||||
|
const ROLE_MAP = {
|
||||||
|
system: extension_prompt_roles.SYSTEM,
|
||||||
|
user: extension_prompt_roles.USER,
|
||||||
|
assistant: extension_prompt_roles.ASSISTANT,
|
||||||
|
};
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
// 工具:执行斜杠命令
|
// 工具:执行斜杠命令
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
@@ -1300,11 +1307,16 @@ async function handleGenerationStarted(type, _params, isDryRun) {
|
|||||||
if (!text.trim()) return;
|
if (!text.trim()) return;
|
||||||
|
|
||||||
// 4) 写入 extension_prompts
|
// 4) 写入 extension_prompts
|
||||||
|
// 获取用户配置的 role
|
||||||
|
const cfg = getSummaryPanelConfig();
|
||||||
|
const roleKey = cfg.trigger?.role || 'system';
|
||||||
|
const role = ROLE_MAP[roleKey] || extension_prompt_roles.SYSTEM;
|
||||||
|
|
||||||
extension_prompts[EXT_PROMPT_KEY] = {
|
extension_prompts[EXT_PROMPT_KEY] = {
|
||||||
value: text,
|
value: text,
|
||||||
position: extension_prompt_types.IN_CHAT,
|
position: extension_prompt_types.IN_CHAT,
|
||||||
depth,
|
depth,
|
||||||
role: extension_prompt_roles.SYSTEM,
|
role,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user