技能清单改 {APP_SKILLS} 占位符就地注入模板,不再盲拼尾部
- llm.js:systemPromptText 拼装时把模板内的 {APP_SKILLS} 替换为技能清单(split/join 支持多处);默认模板没放占位符时兑底尾拼,自定义 prompt 没放则无技能段(语言指令仍尾拼);清单为空时替换后压掉多余空行
- system-prompt.txt:Skill Usage 节尾部放占位符,措辞由「(if present) 找 ## Available Skills 段落」改为直读下方清单;mini-system.txt 同步
- 顺手修 config.example.yml 里误写的 // 注释行;文档语义同步
This commit is contained in:
+17
-6
@@ -54,15 +54,27 @@ function setProfilePrompts(map) {
|
||||
let _promptTextCache = new Map(); // 'profile\u0000lang' -> text
|
||||
|
||||
// “可用技能”段落(skills.formatSkillListForPrompt):启动时快照(server.js)与技能变更后
|
||||
// (routes/skills.js)经 setSkillListText 更新,拼在默认模板之后、语言指令之前。
|
||||
// 与语言指令同一约定:仅技能增删/描述变化时更新,否则进程内恒定,不破坏前缀缓存。
|
||||
// 只拼默认模板:profile 自定义 prompt 完全接管(技能工具若在其白名单内,模型用 list_skills 自取)。
|
||||
//(routes/skills.js)经 setSkillListText 更新。插入位置由模板内的 {APP_SKILLS} 占位符决定
|
||||
//(拼在技能规则旁边,模型一眼看到清单,不再盲猜尾部多出来的孤儿段落):
|
||||
// - 模板含占位符 → 就地替换(默认模板与自定义 prompt 同机制);
|
||||
// - 默认模板没占位符 → 兑底尾拼(兼容手改模板时删掉了占位行);自定义 prompt 没占位符 → 无技能段(完全接管)。
|
||||
// 仅技能增删/描述变化时更新,否则进程内恒定,不破坏前缀缓存。
|
||||
const APP_SKILLS_TOKEN = '{APP_SKILLS}';
|
||||
let SKILL_LIST_TEXT = '';
|
||||
function setSkillListText(text) {
|
||||
SKILL_LIST_TEXT = text || '';
|
||||
_promptTextCache = new Map(); // 列表变化后拼接结果需重建
|
||||
}
|
||||
|
||||
function withSkillList(text, appendFallback) {
|
||||
if (text.includes(APP_SKILLS_TOKEN)) {
|
||||
// split/join:替掉所有出现位;清单为空时顺手压掉替换留下的空行
|
||||
return text.split(APP_SKILLS_TOKEN).join(SKILL_LIST_TEXT).replace(/\n{3,}/g, '\n\n').trim();
|
||||
}
|
||||
if (appendFallback && SKILL_LIST_TEXT) text += '\n\n' + SKILL_LIST_TEXT;
|
||||
return text;
|
||||
}
|
||||
|
||||
function systemPromptText(language, profile) {
|
||||
const t = String(language || '').trim();
|
||||
const key = (profile || 'default') + '\u0000' + t;
|
||||
@@ -70,10 +82,9 @@ function systemPromptText(language, profile) {
|
||||
if (hit) return hit;
|
||||
let text;
|
||||
if (profile && PROFILE_PROMPTS[profile]) {
|
||||
text = PROFILE_PROMPTS[profile];
|
||||
text = withSkillList(PROFILE_PROMPTS[profile], false); // 自定义文件:没放占位符就真没有技能段
|
||||
} else {
|
||||
text = SYSTEM_PROMPT_TEMPLATE;
|
||||
if (SKILL_LIST_TEXT) text += '\n\n' + SKILL_LIST_TEXT;
|
||||
text = withSkillList(SYSTEM_PROMPT_TEMPLATE, true);
|
||||
}
|
||||
if (t) text += '\n\n## Reply Language\n' +
|
||||
'- ALWAYS respond to the user in ' + t + '. Tool descriptions, tool outputs and errors are usually in English — ' +
|
||||
|
||||
@@ -38,10 +38,12 @@ For out-of-scope requests: state the limit in one or two sentences, don't over-a
|
||||
|
||||
## Skills
|
||||
|
||||
- Prefer skills when they match. The Available Skills list is current — call them directly, no need for `list_skills`.
|
||||
- Prefer skills when they match. The Available Skills list below is current — call them directly, no need for `list_skills`.
|
||||
- Use `get_skill_info` for parameters, then `run_skill` to execute.
|
||||
- Skills run in the server's managed Python env; you cannot install packages for them at runtime. If `run_skill` fails for a missing package or system tool, tell the user it needs a server-side change.
|
||||
|
||||
{APP_SKILLS}
|
||||
|
||||
## Files
|
||||
|
||||
- Work inside the working directory. Use clear file names.
|
||||
|
||||
@@ -50,12 +50,14 @@ You are a file / data / information processing assistant. The environment expose
|
||||
## Skill Usage
|
||||
|
||||
- Prefer using available skills when they match the task.
|
||||
- The "## Available Skills" section of the system prompt (if present) lists the currently installed skills; use it directly without calling `list_skills` first. If the section is absent or seems stale (e.g. a listed skill does not exist), call `list_skills` to check live.
|
||||
- The "Available Skills" list below shows the currently installed skills; use it directly without calling `list_skills` first. If the list is empty or seems stale (e.g. a listed skill does not exist), call `list_skills` to check live.
|
||||
- Use `get_skill_info` to understand a skill's parameters, then `run_skill` to execute it.
|
||||
- Only if no skill matches, proceed with other tools or write your own solution.
|
||||
- The listed skills are prepared and ready at server startup; do not try to install dependencies for a skill yourself.
|
||||
- Skills run on the server's managed Python environment; you cannot add packages to a skill at runtime. If `run_skill` fails due to a missing package or system tool, report it to the user — the skill needs a server-side change.
|
||||
|
||||
{APP_SKILLS}
|
||||
|
||||
## File Management
|
||||
|
||||
- Work inside the working directory. Use clear file names.
|
||||
|
||||
Reference in New Issue
Block a user