refactor(ai): 优化 AI 提示词构建逻辑

- withLanguagePreferencePrompt: 修复无语言标签时占位符未添加的问题
- handleBeforeSend: 简化操作会话提示词,移除冗余的工具名称说明

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kuaifan 2026-01-20 13:47:25 +00:00
parent 2180998e81
commit cb5e7e2cc7
2 changed files with 3 additions and 5 deletions

View File

@ -405,7 +405,7 @@ export default {
//
let operationContext = '';
if (this.operationSessionId) {
operationContext = `\n\n前端操作会话已建立,session_id: ${this.operationSessionId}。你可以使用 get_page_context、execute_action、execute_element_action 工具直接操作用户的页面`;
operationContext = `\n\n页面操作会话 session_id: ${this.operationSessionId}`;
}
const prepared = [

View File

@ -360,10 +360,8 @@ const withLanguagePreferencePrompt = (prompt) => {
return prompt;
}
const label = languageList[languageName] || languageName || '';
if (!label) {
return prompt;
}
return `${prompt}\n\n${LANGUAGE_PREFERENCE_PROMPT(label)}\n\n${SYSTEM_OPTIONAL_PROMPTS_PLACEHOLDER}`;
const languagePart = label ? `\n\n${LANGUAGE_PREFERENCE_PROMPT(label)}` : '';
return `${prompt}${languagePart}\n\n${SYSTEM_OPTIONAL_PROMPTS_PLACEHOLDER}`;
};
/**