update
This commit is contained in:
parent
cb0db1248c
commit
4fff6f0956
@ -95,6 +95,7 @@ interface ChatMessage {
|
|||||||
tool: string
|
tool: string
|
||||||
tool_input: string
|
tool_input: string
|
||||||
}
|
}
|
||||||
|
tools?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const userInput = ref('')
|
const userInput = ref('')
|
||||||
@ -164,6 +165,7 @@ const sendMessage = async () => {
|
|||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: 'AI 正在思考...',
|
content: 'AI 正在思考...',
|
||||||
files: [],
|
files: [],
|
||||||
|
tools: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
await scrollToBottom()
|
await scrollToBottom()
|
||||||
@ -217,14 +219,42 @@ const sendMessage = async () => {
|
|||||||
|
|
||||||
switch (data.event) {
|
switch (data.event) {
|
||||||
case 'agent_thought':
|
case 'agent_thought':
|
||||||
// 忽略思考过程
|
// 记录使用的工具
|
||||||
|
if (data.tool) {
|
||||||
|
if (!chatHistory.value[tempMessageIndex].tools) {
|
||||||
|
chatHistory.value[tempMessageIndex].tools = []
|
||||||
|
}
|
||||||
|
chatHistory.value[tempMessageIndex].tools?.push(data.tool)
|
||||||
|
|
||||||
|
// 更新显示的工具列表
|
||||||
|
let toolsText = ''
|
||||||
|
chatHistory.value[tempMessageIndex].tools?.forEach((tool, index) => {
|
||||||
|
toolsText += `${index + 1}.已使用 ${tool}\n`
|
||||||
|
})
|
||||||
|
|
||||||
|
if (responseText) {
|
||||||
|
chatHistory.value[tempMessageIndex].content = toolsText + '\n' + responseText
|
||||||
|
} else {
|
||||||
|
chatHistory.value[tempMessageIndex].content = toolsText
|
||||||
|
}
|
||||||
|
await scrollToBottom()
|
||||||
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'agent_message':
|
case 'agent_message':
|
||||||
if (data.answer) {
|
if (data.answer) {
|
||||||
responseText += data.answer
|
responseText += data.answer
|
||||||
// 更新临时助手消息的内容
|
|
||||||
chatHistory.value[tempMessageIndex].content = responseText
|
// 更新临时助手消息的内容,保留工具列表
|
||||||
|
let toolsText = ''
|
||||||
|
if (chatHistory.value[tempMessageIndex].tools?.length) {
|
||||||
|
chatHistory.value[tempMessageIndex].tools?.forEach((tool, index) => {
|
||||||
|
toolsText += `${index + 1}.已使用 ${tool}\n`
|
||||||
|
})
|
||||||
|
chatHistory.value[tempMessageIndex].content = toolsText + '\n' + responseText
|
||||||
|
} else {
|
||||||
|
chatHistory.value[tempMessageIndex].content = responseText
|
||||||
|
}
|
||||||
await scrollToBottom()
|
await scrollToBottom()
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user