ss
This commit is contained in:
@@ -179,6 +179,7 @@ const inputMessage = ref('')
|
||||
const loading = ref(false)
|
||||
const messagesContainer = ref<HTMLElement>()
|
||||
let pollingInterval: any = null
|
||||
let replyAdded = false // 标志位:防止重复添加回复
|
||||
|
||||
// 发送消息
|
||||
const handleSendMessage = async () => {
|
||||
@@ -210,9 +211,17 @@ const handleSendMessage = async () => {
|
||||
|
||||
const execution = response.data
|
||||
|
||||
// 重置标志位
|
||||
replyAdded = false
|
||||
|
||||
// 轮询执行状态
|
||||
const checkStatus = async () => {
|
||||
try {
|
||||
// 如果已经添加过回复,直接返回,避免重复添加
|
||||
if (replyAdded) {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取详细执行状态(包含节点执行信息)
|
||||
const statusResponse = await api.get(`/api/v1/executions/${execution.id}/status`)
|
||||
const status = statusResponse.data
|
||||
@@ -225,6 +234,14 @@ const handleSendMessage = async () => {
|
||||
const exec = execResponse.data
|
||||
|
||||
if (exec.status === 'completed') {
|
||||
// 防止重复添加:如果已经添加过回复,直接返回
|
||||
if (replyAdded) {
|
||||
return
|
||||
}
|
||||
|
||||
// 标记已添加回复
|
||||
replyAdded = true
|
||||
|
||||
// 提取Agent回复
|
||||
let agentReply = ''
|
||||
if (exec.output_data) {
|
||||
@@ -268,6 +285,14 @@ const handleSendMessage = async () => {
|
||||
pollingInterval = null
|
||||
}
|
||||
} else if (exec.status === 'failed') {
|
||||
// 防止重复添加:如果已经添加过回复,直接返回
|
||||
if (replyAdded) {
|
||||
return
|
||||
}
|
||||
|
||||
// 标记已添加回复
|
||||
replyAdded = true
|
||||
|
||||
messages.value.push({
|
||||
role: 'agent',
|
||||
content: `执行失败: ${exec.error_message || '未知错误'}`,
|
||||
@@ -290,6 +315,14 @@ const handleSendMessage = async () => {
|
||||
// 不需要做任何操作,等待下次轮询
|
||||
}
|
||||
} catch (error: any) {
|
||||
// 防止重复添加:如果已经添加过回复,直接返回
|
||||
if (replyAdded) {
|
||||
return
|
||||
}
|
||||
|
||||
// 标记已添加回复
|
||||
replyAdded = true
|
||||
|
||||
messages.value.push({
|
||||
role: 'agent',
|
||||
content: `获取执行结果失败: ${error.response?.data?.detail || error.message}`,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user