2023-06-15 11:31:03 +04:00
|
|
|
import { nanoid } from '@/lib/utils'
|
2023-06-11 00:23:23 +04:00
|
|
|
import { Chat } from '@/components/chat'
|
2024-03-14 20:00:52 +03:00
|
|
|
import { AI } from '@/lib/chat/actions'
|
|
|
|
|
import { auth } from '@/auth'
|
|
|
|
|
import { Session } from '@/lib/types'
|
2024-04-29 19:12:17 +06:00
|
|
|
import { getMissingKeys } from '@/app/actions'
|
2023-05-19 12:33:56 -04:00
|
|
|
|
2024-03-14 20:00:52 +03:00
|
|
|
export const metadata = {
|
|
|
|
|
title: 'Next.js AI Chatbot'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default async function IndexPage() {
|
2023-06-15 11:31:03 +04:00
|
|
|
const id = nanoid()
|
2024-03-14 20:00:52 +03:00
|
|
|
const session = (await auth()) as Session
|
|
|
|
|
const missingKeys = await getMissingKeys()
|
2023-06-15 11:31:03 +04:00
|
|
|
|
2024-03-14 20:00:52 +03:00
|
|
|
return (
|
|
|
|
|
<AI initialAIState={{ chatId: id, messages: [] }}>
|
|
|
|
|
<Chat id={id} session={session} missingKeys={missingKeys} />
|
|
|
|
|
</AI>
|
|
|
|
|
)
|
2023-05-19 12:33:56 -04:00
|
|
|
}
|