fix(agent): 修复流式推理与工具参数重试
This commit is contained in:
@@ -30,6 +30,7 @@ export type CloudAgentChatMessage = {
|
||||
title?: string;
|
||||
text: string;
|
||||
streaming?: boolean;
|
||||
reasoning?: boolean;
|
||||
meta?: string;
|
||||
detail?: unknown;
|
||||
attachments?: CloudAgentChatAttachment[];
|
||||
@@ -91,6 +92,12 @@ export function AgentChatMessage({
|
||||
const isUser = item.role === "user";
|
||||
const isSystem = item.role === "system";
|
||||
const color = item.role === "error" ? "#ef4444" : theme.node.text;
|
||||
if (item.reasoning) {
|
||||
return <details className="min-w-0 text-xs" style={{ color: theme.node.muted }}>
|
||||
<summary className="cursor-pointer py-1 focus-visible:outline-auto">{item.streaming ? "模型推理中" : "模型推理摘要"}</summary>
|
||||
<div className="max-h-64 overflow-auto whitespace-pre-wrap break-words py-2" data-canvas-wheel-scroll>{item.text}</div>
|
||||
</details>;
|
||||
}
|
||||
if (isSystem) {
|
||||
return (
|
||||
<div className="flex items-start gap-3 text-xs">
|
||||
|
||||
@@ -1090,6 +1090,12 @@ function applyAgentEvent(event: AgentEvent, setMessages: Dispatch<SetStateAction
|
||||
setMessages((current) => upsertTextMessage(current, String(payload.messageId || "assistant"), text, true));
|
||||
return;
|
||||
}
|
||||
if (event.type === "reasoning_delta" || event.type === "reasoning_message") {
|
||||
const id = String(payload.messageId || `${event.runId}:reasoning`);
|
||||
setMessages((current) => upsertTextMessage(current, id, text, event.type === "reasoning_delta")
|
||||
.map((item) => item.id === id ? { ...item, reasoning: true } : item));
|
||||
return;
|
||||
}
|
||||
if (event.type === "assistant_message") {
|
||||
setMessages((current) => upsertTextMessage(current, String(payload.messageId || event.eventId), text, false));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user