feat: 优化内置智能体配置同步机制

改进内置智能体与自定义智能体的配置合并逻辑,确保内置智能体能正确应用API配置和默认值,同时优化了系统提示词的分离管理。
This commit is contained in:
wizardchen
2025-12-30 13:45:36 +08:00
committed by lyingbug
parent c2c4ee5777
commit 89e75bb6fe
4 changed files with 61 additions and 31 deletions
+13 -13
View File
@@ -959,7 +959,8 @@ const kbOptions = ref<{ label: string; value: string; type?: 'document' | 'faq';
const mcpOptions = ref<{ label: string; value: string }[]>([]);
// 系统默认配置(用于内置智能体显示默认提示词)
const defaultSystemPrompt = ref(''); // 统一的默认系统提示词
const defaultAgentSystemPrompt = ref(''); // Agent 模式的默认系统提示词(来自 agent-config)
const defaultNormalSystemPrompt = ref(''); // 普通模式的默认系统提示词(来自 conversation-config)
const defaultContextTemplate = ref('');
const defaultRewritePromptSystem = ref('');
const defaultRewritePromptUser = ref('');
@@ -1295,14 +1296,14 @@ const fillBuiltinAgentDefaults = () => {
const isAgent = config.agent_mode === 'smart-reasoning';
if (isAgent) {
// Agent 模式:填入统一的默认提示词
if (!config.system_prompt && defaultSystemPrompt.value) {
config.system_prompt = defaultSystemPrompt.value;
// Agent 模式:使用 agent-config 的默认提示词
if (!config.system_prompt && defaultAgentSystemPrompt.value) {
config.system_prompt = defaultAgentSystemPrompt.value;
}
} else {
// 普通模式:填入默认系统提示词和上下文模板
if (!config.system_prompt && defaultSystemPrompt.value) {
config.system_prompt = defaultSystemPrompt.value;
// 普通模式:使用 conversation-config 的默认系统提示词和上下文模板
if (!config.system_prompt && defaultNormalSystemPrompt.value) {
config.system_prompt = defaultNormalSystemPrompt.value;
}
if (!config.context_template && defaultContextTemplate.value) {
config.context_template = defaultContextTemplate.value;
@@ -1458,17 +1459,16 @@ const loadDependencies = async () => {
console.warn('Failed to load placeholders', e);
}
// 加载 Agent 模式默认提示词(统一提示词)
// 加载 Agent 模式默认提示词(来自 agent-config,用于 smart-reasoning 模式)
const agentConfig = await getAgentConfig();
if (agentConfig.data?.system_prompt) {
defaultSystemPrompt.value = agentConfig.data.system_prompt;
defaultAgentSystemPrompt.value = agentConfig.data.system_prompt;
}
// 加载系统默认配置(用于普通模式)
// 加载系统默认配置(来自 conversation-config,用于普通模式 quick-answer)
const conversationConfig = await getConversationConfig();
if (conversationConfig.data?.prompt && !defaultSystemPrompt.value) {
// 如果 Agent 配置没有提供默认提示词,则使用普通模式的
defaultSystemPrompt.value = conversationConfig.data.prompt;
if (conversationConfig.data?.prompt) {
defaultNormalSystemPrompt.value = conversationConfig.data.prompt;
}
if (conversationConfig.data?.context_template) {
defaultContextTemplate.value = conversationConfig.data.context_template;