mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-15 22:18:00 +00:00
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import {
|
|
ChatMessage,
|
|
type ChatMessageProps,
|
|
type Message,
|
|
} from "@/components/chat-playground/chat-message";
|
|
import { TypingIndicator } from "@/components/chat-playground/typing-indicator";
|
|
|
|
type AdditionalMessageOptions = Omit<ChatMessageProps, keyof Message>;
|
|
|
|
interface MessageListProps {
|
|
messages: Message[];
|
|
showTimeStamps?: boolean;
|
|
isTyping?: boolean;
|
|
messageOptions?:
|
|
| AdditionalMessageOptions
|
|
| ((message: Message) => AdditionalMessageOptions);
|
|
}
|
|
|
|
export function MessageList({
|
|
messages,
|
|
showTimeStamps = true,
|
|
isTyping = false,
|
|
messageOptions,
|
|
}: MessageListProps) {
|
|
return (
|
|
<div className="space-y-4 overflow-visible">
|
|
{messages.map((message, index) => {
|
|
const additionalOptions =
|
|
typeof messageOptions === "function"
|
|
? messageOptions(message)
|
|
: messageOptions;
|
|
|
|
return (
|
|
<ChatMessage
|
|
key={index}
|
|
showTimeStamp={showTimeStamps}
|
|
{...message}
|
|
{...additionalOptions}
|
|
/>
|
|
);
|
|
})}
|
|
{isTyping && <TypingIndicator />}
|
|
</div>
|
|
);
|
|
}
|