feat: 切换Agent自动创建新对话
This commit is contained in:
@@ -206,10 +206,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换Agent
|
// 切换Agent - 自动创建新对话
|
||||||
function switchAgent() {
|
async function switchAgent() {
|
||||||
const newAgentId = document.getElementById('agentSelect').value;
|
const newAgentId = document.getElementById('agentSelect').value;
|
||||||
if (newAgentId && newAgentId !== currentAgentId) {
|
if (newAgentId && parseInt(newAgentId) !== currentAgentId) {
|
||||||
|
const oldAgentId = currentAgentId;
|
||||||
currentAgentId = parseInt(newAgentId);
|
currentAgentId = parseInt(newAgentId);
|
||||||
console.log('切换Agent:', currentAgentId);
|
console.log('切换Agent:', currentAgentId);
|
||||||
|
|
||||||
@@ -221,6 +222,9 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 自动创建新对话
|
||||||
|
await createNewConversation();
|
||||||
|
|
||||||
// 显示切换提示
|
// 显示切换提示
|
||||||
const agent = agents.find(a => a.id === currentAgentId);
|
const agent = agents.find(a => a.id === currentAgentId);
|
||||||
if (agent) {
|
if (agent) {
|
||||||
@@ -232,19 +236,14 @@
|
|||||||
// 显示Agent切换提示
|
// 显示Agent切换提示
|
||||||
function showAgentSwitchNotice(agentName) {
|
function showAgentSwitchNotice(agentName) {
|
||||||
const container = document.getElementById('messagesContainer');
|
const container = document.getElementById('messagesContainer');
|
||||||
const notice = document.createElement('div');
|
// 清空现有内容,显示切换提示
|
||||||
notice.className = 'message assistant';
|
container.innerHTML = `
|
||||||
notice.innerHTML = `
|
<div class="welcome">
|
||||||
<div class="message-avatar">🔄</div>
|
<h2>🔄 已切换 Agent</h2>
|
||||||
<div class="message-content" style="color:#667eea;font-size:14px;">
|
<p style="color:#667eea;font-size:18px;"><strong>${agentName}</strong></p>
|
||||||
已切换到 Agent: <strong>${agentName}</strong>,开始新对话生效
|
<p style="color:#999;font-size:14px;">已为您创建新对话,可直接开始聊天</p>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
container.appendChild(notice);
|
|
||||||
container.scrollTop = container.scrollHeight;
|
|
||||||
|
|
||||||
// 3秒后移除提示
|
|
||||||
setTimeout(() => notice.remove(), 3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载快捷语句
|
// 加载快捷语句
|
||||||
|
|||||||
Reference in New Issue
Block a user