Spaces:
Running
Running
File size: 924 Bytes
6e29063 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import { Group, Text } from "@mantine/core";
import type { ChatMessage } from "gpt-tokenizer/GptEncoding";
import { Suspense, lazy } from "react";
const CopyIconButton = lazy(() => import("./CopyIconButton"));
interface ChatHeaderProps {
messages: ChatMessage[];
}
function ChatHeader({ messages }: ChatHeaderProps) {
const getChatContent = () => {
return messages
.slice(2)
.map(
(msg, index) =>
`${index + 1}. ${msg.role?.toUpperCase()}\n\n${msg.content}`,
)
.join("\n\n");
};
return (
<Group justify="space-between">
<Text fw={500}>Follow-up questions</Text>
{messages.length > 2 && (
<Suspense fallback={<Text size="xs">Loading...</Text>}>
<CopyIconButton
value={getChatContent()}
tooltipLabel="Copy conversation"
/>
</Suspense>
)}
</Group>
);
}
export default ChatHeader;
|