File size: 1,135 Bytes
f3a9ef2
a86b547
f3a9ef2
 
052672d
 
a86b547
 
 
f3a9ef2
 
a86b547
f3a9ef2
 
a86b547
 
f80b091
a86b547
f3a9ef2
f80b091
 
76a5b74
 
97e41aa
 
f80b091
 
a86b547
f80b091
38448fc
f80b091
 
 
 
 
 
 
a86b547
f80b091
 
f3a9ef2
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
'use client';

import { cn } from '@/lib/utils';
import { ChatList } from '@/components/chat/ChatList';
import { ChatPanel } from '@/components/chat/ChatPanel';
import { ChatScrollAnchor } from '@/components/chat/ChatScrollAnchor';
import { ChatEntity } from '@/lib/types';
import Image from 'next/image';
import useVisionAgent from '@/lib/hooks/useVisionAgent';

export interface ChatProps extends React.ComponentProps<'div'> {
  chat: ChatEntity;
}

export function Chat({ chat }: ChatProps) {
  const { url, id } = chat;
  const { messages, append, reload, stop, isLoading, input, setInput } =
    useVisionAgent(chat);

  return (
    <>
      <div className={cn('pb-[250px] pt-4 md:pt-10 h-full')}>
        <div className="size-full overflow-auto">
          <ChatList messages={messages} />
          <ChatScrollAnchor trackVisibility={isLoading} />
        </div>
      </div>
      <ChatPanel
        id={id}
        url={url}
        isLoading={isLoading}
        stop={stop}
        append={append}
        reload={reload}
        messages={messages}
        input={input}
        setInput={setInput}
      />
    </>
  );
}