技能清单改 {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:
@@ -46,14 +46,15 @@ platforms:
|
||||
# 模型 profile(可选):预定义多套「prompt + tools 白名单」组合,platforms 里的模型用
|
||||
# profile: <名字> 引用,同 id 模型跨平台复用时免重复配置。动机:默认发给模型的
|
||||
# 内置工具 schema + system prompt 合计 ~20KB 字符(约 6K token),对特别小的模型会撑爆上下文。
|
||||
// - tools_allow:白名单(字符串数组),只保留名单内的工具发给模型;内置名 + MCP 最终名
|
||||
// (含冲突时加的 服务名__ 前缀,与 data/prompt.txt dump 一致可对)。不配 = 全量发;
|
||||
// 空数组 [] = 一个都不发(纯文本模式,给弱到不会调工具的小模型;与 MCP 的 tools_allow
|
||||
// 「空名单视作未配」约定有意不同)。只影响模型「看得到什么」:名单外但真实存在的工具若被调用,
|
||||
// 后端照常执行,不拦不误杀。
|
||||
# - tools_allow:白名单(字符串数组),只保留名单内的工具发给模型;内置名 + MCP 最终名
|
||||
# (含冲突时加的 服务名__ 前缀,与 data/prompt.txt dump 一致可对)。不配 = 全量发;
|
||||
# 空数组 [] = 一个都不发(纯文本模式,给弱到不会调工具的小模型;与 MCP 的 tools_allow
|
||||
# 「空名单视作未配」约定有意不同)。只影响模型「看得到什么」:名单外但真实存在的工具若被调用,
|
||||
# 后端照常执行,不拦不误杀。
|
||||
# - system_prompt_file:自定义 system prompt 文件,相对 server/templates/(也接受绝对路径),
|
||||
# 配置加载时一次性读入常驻内存;设了就完全接管(不拼技能列表段,只保留末尾语言指令)。
|
||||
# 文件缺失/为空直接校验报错。两者至少配一个;引用不存在的 profile 名同样直接报错。
|
||||
# 配置加载时一次性读入常驻内存;设了即完全接管模板正文(末尾语言指令仍自动拼)。
|
||||
# 想要技能清单在模板里放 {APP_SKILLS} 占位符(拼装时就地替换为已装技能列表;不放 = 没有技能段),
|
||||
# 默认模板同机制。文件缺失/为空直接校验报错。两者至少配一个;引用不存在的 profile 名同样直接报错。
|
||||
# 改本段需重启;运行期前端可在已定义的 profile 间手动切换(发消息带 profile 参数,
|
||||
# 纯内存选择、下一请求即生效,不碰配置文件);列表随 /api/system/status 的 model_profiles 下发。
|
||||
# model_profiles:
|
||||
|
||||
+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