2023-06-11 00:23:23 +04:00
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
import { useChat, type Message } from 'ai-connector'
|
|
|
|
|
import { ChatList } from '@/components/chat-list'
|
|
|
|
|
import { ChatPanel } from '@/components/chat-panel'
|
|
|
|
|
|
|
|
|
|
export interface ChatProps {
|
|
|
|
|
// create?: (input: string) => Chat | undefined;
|
|
|
|
|
initialMessages?: Message[]
|
|
|
|
|
id?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Chat({ id, initialMessages }: ChatProps) {
|
2023-06-11 15:08:59 +04:00
|
|
|
const { messages, append, reload, stop, isLoading } = useChat({
|
2023-06-11 00:23:23 +04:00
|
|
|
initialMessages,
|
|
|
|
|
id
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return (
|
2023-06-11 15:08:59 +04:00
|
|
|
<div className="h-full w-full overflow-auto pt-4 md:pt-10 bg-muted/50 pb-[200px]">
|
|
|
|
|
<ChatList messages={messages} />
|
|
|
|
|
<ChatPanel
|
|
|
|
|
id={id}
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
stop={stop}
|
|
|
|
|
append={append}
|
|
|
|
|
reload={reload}
|
|
|
|
|
messages={messages}
|
|
|
|
|
/>
|
2023-06-11 00:23:23 +04:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|