新增 model_profiles:小模型的 prompt+tools 组合白名单
- 顶层 model_profiles 定义多套组合 {tools_allow?, system_prompt_file?},platforms 里的模型用 profile: <名> 引用(同 id 跨平台复用);引用不存在/文件缺失/空壳组合直接校验报错
- tools_allow 按最终工具名(内置 + MCP,含 server__ 前缀)过滤发给模型的 tools;名单外工具被调用不拦,executor 全表照跑
- system_prompt_file 相对 server/templates/,配置加载时一次读入常驻内存;设了即完全接管(不拼技能段),语言后缀照拼
- 运行期动态切换:发消息带 profile 参数(同 deepThink 约定,每迭代取 run 最新值),纯内存选择、不碰 config.yml;'default'=显式全量,未知名 400
- 压缩回合跟随当前组合;prompt 缓存改 (profile,语言) 键;prompt.txt dump 每套组合各一段;/api/models 带 profile、/api/system/status 下发组合名供前端选择器
This commit is contained in:
@@ -21,7 +21,13 @@ router.post('/:id/messages', wrap((req, res) => {
|
||||
if (!content) return res.status(400).json({ error: 'content 不能为空' });
|
||||
// deepThink:是否启用模型该「深度思考」参数(thinking_params 合并进上游请求体)
|
||||
const deepThink = !!(req.body && req.body.deepThink);
|
||||
const r = engine.postUserMessage(req.params.id, content, { deepThink });
|
||||
// profile:本轮 prompt+tools 组合(config.yml 顶层 model_profiles 的名字;保留值 'default' = 显式全量;
|
||||
// 不传 = 随模型配置的 profile)。名字不存在直接 400 打回,不静默回退(难排查)。
|
||||
const profile = String((req.body && req.body.profile) || '').trim();
|
||||
if (profile && profile !== 'default' && !engine.hasModelProfile(profile)) {
|
||||
return res.status(400).json({ error: 'profile 不存在:' + profile + '(可选:' + Object.keys(engine.getConfig().model_profiles || {}).join(', ') + ')' });
|
||||
}
|
||||
const r = engine.postUserMessage(req.params.id, content, { deepThink, profile });
|
||||
log.info('msg', (req.user || '-') + ' ' + req.params.id + ' 用户消息(' + (r && r.delivered || '?') + '):' +
|
||||
content.slice(0, 60).replace(/\s+/g, ' '));
|
||||
res.json(r);
|
||||
|
||||
Reference in New Issue
Block a user