wuyiqunLu
feat: support image rendering on answer (#19)
5d7d435 unverified
raw
history blame
1.43 kB
'use client';
import { cn } from '@/lib/utils';
import { ChatList } from '@/components/chat/ChatList';
import { ChatPanel } from '@/components/chat/ChatPanel';
import { ChatEntity } from '@/lib/types';
import Image from 'next/image';
import useVisionAgent from '@/lib/hooks/useVisionAgent';
import { useScrollAnchor } from '@/lib/hooks/useScrollAnchor';
import { ButtonScrollToBottom } from '../ui/ButtonScrollToBottom';
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);
const { messagesRef, scrollRef, visibilityRef, isAtBottom, scrollToBottom } =
useScrollAnchor();
return (
<>
<div className="h-full overflow-auto" ref={scrollRef}>
<div className="pb-[200px] pt-4 md:pt-10" ref={messagesRef}>
<ChatList messages={messages} />
<div className="h-px w-full" ref={visibilityRef} />
</div>
</div>
<ChatPanel
id={id}
url={url}
isLoading={isLoading}
stop={stop}
append={append}
reload={reload}
messages={messages}
input={input}
setInput={setInput}
/>
<ButtonScrollToBottom
isAtBottom={isAtBottom}
scrollToBottom={scrollToBottom}
/>
</>
);
}