import type { PlaygroundChatMessage } from '@/types/playground' import { AgentMessage, UserMessage } from './MessageItem' import Tooltip from '@/components/ui/tooltip' import { memo } from 'react' import { ToolCallProps, ReasoningStepProps, ReasoningProps, ReferenceData, Reference } from '@/types/playground' import React, { type FC } from 'react' import ChatBlankState from './ChatBlankState' import Icon from '@/components/ui/icon' interface MessageListProps { messages: PlaygroundChatMessage[] } interface MessageWrapperProps { message: PlaygroundChatMessage isLastMessage: boolean } interface ReferenceProps { references: ReferenceData[] } interface ReferenceItemProps { reference: Reference } const ReferenceItem: FC = ({ reference }) => (

{reference.name}

{reference.content}

) const References: FC = ({ references }) => (
{references.map((referenceData, index) => (
{referenceData.references.map((reference, refIndex) => ( ))}
))}
) const AgentMessageWrapper = ({ message }: MessageWrapperProps) => { return (
{message.extra_data?.reasoning_steps && message.extra_data.reasoning_steps.length > 0 && (
Reasoning

} side="top" >

Reasoning

)} {message.extra_data?.references && message.extra_data.references.length > 0 && (
References

} side="top" >
)} {message.tool_calls && message.tool_calls.length > 0 && (
Tool Calls

} side="top" >
{message.tool_calls.map((toolCall, index) => ( ))}
)}
) } const Reasoning: FC = ({ index, stepTitle }) => (

STEP {index + 1}

{stepTitle}

) const Reasonings: FC = ({ reasoning }) => (
{reasoning.map((title, index) => ( ))}
) const ToolComponent = memo(({ tools }: ToolCallProps) => (

{tools.tool_name}

)) ToolComponent.displayName = 'ToolComponent' const Messages = ({ messages }: MessageListProps) => { if (messages.length === 0) { return } return ( <> {messages.map((message, index) => { const key = `${message.role}-${message.created_at}-${index}` const isLastMessage = index === messages.length - 1 if (message.role === 'agent') { return ( ) } return })} ) } export default Messages