File size: 2,283 Bytes
edd2230
 
c69ef3e
052672d
a86b547
58d7e55
 
 
3ba9c0c
 
a86b547
58d7e55
5613eec
3ba9c0c
 
5613eec
f80b091
96ac62a
58d7e55
 
 
 
 
 
 
58fe8e1
085b520
 
39c238d
 
 
 
 
085b520
 
 
 
 
 
 
 
 
 
 
 
 
58d7e55
 
 
 
 
f80b091
8c5e6e1
f80b091
 
5613eec
 
 
 
f80b091
 
 
 
 
 
 
3ba9c0c
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use client';

import { Separator } from '@/components/ui/Separator';
import { ChatMessage } from '@/components/chat/ChatMessage';
import { MessageBase } from '../../lib/types';
import { Session } from 'next-auth';
import { IconExclamationTriangle } from '../ui/Icons';
import Link from 'next/link';

export interface ChatList {
  messages: MessageBase[];
  session: Session | null;
  isLoading: boolean;
}

export function ChatList({ messages, session, isLoading }: ChatList) {
  return (
    <div className="relative mx-auto max-w-5xl px-8 pr-12">
      {!session && (
        <>
          <div className="group relative mb-4 flex items-center">
            <div className="bg-background flex size-8 shrink-0 select-none items-center justify-center rounded-md border shadow">
              <IconExclamationTriangle />
            </div>
            <div className="flex-1 px-1 ml-4 space-y-2 overflow-hidden">
              {process.env.NEXT_PUBLIC_IS_HUGGING_FACE ? (
                <p className="text-muted-foreground leading-normal">
                  Please visit and login into{' '}
                  <Link
                    href="https://va.landing.ai/"
                    target="_blank"
                    className="underline"
                  >
                    our landing website
                  </Link>{' '}
                  to save and revisit your chat history!
                </p>
              ) : (
                <p className="text-muted-foreground leading-normal">
                  Please{' '}
                  <Link href="/sign-in" className="underline">
                    log in
                  </Link>{' '}
                  to save and revisit your chat history!
                </p>
              )}
            </div>
          </div>
          <Separator className="my-4" />
        </>
      )}
      {messages
        // .filter(message => message.role !== 'system')
        .map((message, index) => (
          <div key={index}>
            <ChatMessage
              message={message}
              isLoading={isLoading && index === messages.length - 1}
            />
            {index < messages.length - 1 && (
              <Separator className="my-4 md:my-8" />
            )}
          </div>
        ))}
    </div>
  );
}