import { UIMessage, ToolCallPart, ToolResultPart } from "ai"; import { Response } from "@/components/ai-elements/response"; import { ReasoningPart } from "./reasoning-part"; import { ToolCall, ToolResult } from "./tool-call"; export function AssistantMessage({ message, status, isLastMessage, durations, onDurationChange }: { message: UIMessage; status?: string; isLastMessage?: boolean; durations?: Record; onDurationChange?: (key: string, duration: number) => void }) { return (
{message.parts.map((part, i) => { const isStreaming = status === "streaming" && isLastMessage && i === message.parts.length - 1; const durationKey = `${message.id}-${i}`; const duration = durations?.[durationKey]; if (part.type === "text") { return {part.text}; } else if (part.type === "reasoning") { return ( onDurationChange(durationKey, d) : undefined} /> ); } else if ( part.type.startsWith("tool-") || part.type === "dynamic-tool" ) { if ('state' in part && part.state === "output-available") { return ( ); } else { return ( ); } } return null; })}
) }