File size: 775 Bytes
ed8833e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Group, Text } from "@mantine/core";
import type { ChatMessage } from "gpt-tokenizer/GptEncoding";
import CopyIconButton from "./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 && (
        <CopyIconButton
          value={getChatContent()}
          tooltipLabel="Copy conversation"
        />
      )}
    </Group>
  );
}

export default ChatHeader;