"use client"; import { ChatMessage, ChatCompletion } from "@/lib/types"; import { ChatMessageItem } from "@/components/chat-completions/chat-messasge-item"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { DetailLoadingView, DetailErrorView, DetailNotFoundView, DetailLayout, PropertiesCard, PropertyItem, } from "@/components/layout/detail-layout"; interface ChatCompletionDetailViewProps { completion: ChatCompletion | null; isLoading: boolean; error: Error | null; id: string; } export function ChatCompletionDetailView({ completion, isLoading, error, id, }: ChatCompletionDetailViewProps) { const title = "Chat Completion Details"; if (error) { return ; } if (isLoading) { return ; } if (!completion) { return ; } // Main content cards const mainContent = ( <> Input {completion.input_messages?.map((msg, index) => ( ))} {completion.choices?.[0]?.message?.tool_calls && Array.isArray(completion.choices[0].message.tool_calls) && !completion.input_messages?.some( (im) => im.role === "assistant" && im.tool_calls && Array.isArray(im.tool_calls) && im.tool_calls.length > 0, ) ? completion.choices[0].message.tool_calls.map( (toolCall: any, index: number) => { const assistantToolCallMessage: ChatMessage = { role: "assistant", tool_calls: [toolCall], content: "", // Ensure content is defined, even if empty }; return ( ); }, ) : null} Output {completion.choices?.[0]?.message ? ( ) : ( No message found in assistant's choice. )} > ); // Properties sidebar const sidebar = ( {(() => { const toolCalls = completion.choices?.[0]?.message?.tool_calls; if (toolCalls && Array.isArray(toolCalls) && toolCalls.length > 0) { return ( {toolCalls.map((toolCall: any, index: number) => ( {toolCall.function?.name || "N/A"} ))} } hasBorder /> ); } return null; })()} ); return ( ); }
No message found in assistant's choice.