浏览代码

fix:解决tool_call结束了还一直转圈的问题

Jerry Liang 2 月之前
父节点
当前提交
ff13e34c7e
共有 1 个文件被更改,包括 8 次插入 和 0 次删除
  1. 8 0
      src/layout/header/Actions/AiChat/useAiChat.ts

+ 8 - 0
src/layout/header/Actions/AiChat/useAiChat.ts

@@ -564,6 +564,14 @@ export function useAiChat() {
           if (payload.sessionId) {
             currentSessionId.value = payload.sessionId
           }
+          // turn 结束:将所有仍在 running 的 tool call 标记为完成
+          if (aiMessage.toolCalls) {
+            for (const tc of aiMessage.toolCalls) {
+              if (tc.status === 'running') {
+                tc.status = 'completed'
+              }
+            }
+          }
           // 最终扫描:处理跨 chunk 的标记
           extractFileDownloads(aiMessage)
           break