import type { Message } from 'ai'; import { useRef } from 'react'; import { classNames } from '~/utils/classNames'; import { AssistantMessage } from './AssistantMessage'; import { UserMessage } from './UserMessage'; interface MessagesProps { id?: string; classNames?: { root?: string; messagesContainer?: string }; isLoading?: boolean; messages?: Message[]; } export function Messages(props: MessagesProps) { const { id, isLoading, messages = [] } = props; const containerRef = useRef(null); return (
{messages.length > 0 ? messages.map((message, i) => { const { role, content } = message; const isUser = role === 'user'; const isFirst = i === 0; return (
{isUser ? : }
); }) : null} {isLoading &&
}
); }