diff --git a/templates/index.html b/templates/index.html index 5c18947..56259fc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -206,10 +206,11 @@ } } - // 切换Agent - function switchAgent() { + // 切换Agent - 自动创建新对话 + async function switchAgent() { const newAgentId = document.getElementById('agentSelect').value; - if (newAgentId && newAgentId !== currentAgentId) { + if (newAgentId && parseInt(newAgentId) !== currentAgentId) { + const oldAgentId = currentAgentId; currentAgentId = parseInt(newAgentId); console.log('切换Agent:', currentAgentId); @@ -221,6 +222,9 @@ })); } + // 自动创建新对话 + await createNewConversation(); + // 显示切换提示 const agent = agents.find(a => a.id === currentAgentId); if (agent) { @@ -232,19 +236,14 @@ // 显示Agent切换提示 function showAgentSwitchNotice(agentName) { const container = document.getElementById('messagesContainer'); - const notice = document.createElement('div'); - notice.className = 'message assistant'; - notice.innerHTML = ` -
-