2024-10-24 16:35:51 -04:00
|
|
|
import { cookies } from 'next/headers';
|
|
|
|
|
|
2024-11-15 10:14:25 -05:00
|
|
|
import { Chat } from '@/components/chat';
|
2025-02-03 20:33:15 +05:30
|
|
|
import { DEFAULT_CHAT_MODEL } from '@/lib/ai/models';
|
2024-10-24 16:35:51 -04:00
|
|
|
import { generateUUID } from '@/lib/utils';
|
2024-12-19 17:05:04 +05:30
|
|
|
import { DataStreamHandler } from '@/components/data-stream-handler';
|
2023-05-19 12:33:56 -04:00
|
|
|
|
2024-10-11 18:00:22 +05:30
|
|
|
export default async function Page() {
|
|
|
|
|
const id = generateUUID();
|
2024-10-24 16:35:51 -04:00
|
|
|
|
|
|
|
|
const cookieStore = await cookies();
|
2025-02-03 20:33:15 +05:30
|
|
|
const modelIdFromCookie = cookieStore.get('chat-model');
|
2024-10-30 16:01:24 +05:30
|
|
|
|
2025-02-03 20:33:15 +05:30
|
|
|
if (!modelIdFromCookie) {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Chat
|
|
|
|
|
key={id}
|
|
|
|
|
id={id}
|
|
|
|
|
initialMessages={[]}
|
|
|
|
|
selectedChatModel={DEFAULT_CHAT_MODEL}
|
|
|
|
|
selectedVisibilityType="private"
|
|
|
|
|
isReadonly={false}
|
|
|
|
|
/>
|
|
|
|
|
<DataStreamHandler id={id} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-10-24 16:35:51 -04:00
|
|
|
|
|
|
|
|
return (
|
2024-12-19 17:05:04 +05:30
|
|
|
<>
|
|
|
|
|
<Chat
|
|
|
|
|
key={id}
|
|
|
|
|
id={id}
|
|
|
|
|
initialMessages={[]}
|
2025-02-03 20:33:15 +05:30
|
|
|
selectedChatModel={modelIdFromCookie.value}
|
2024-12-19 17:05:04 +05:30
|
|
|
selectedVisibilityType="private"
|
|
|
|
|
isReadonly={false}
|
|
|
|
|
/>
|
|
|
|
|
<DataStreamHandler id={id} />
|
|
|
|
|
</>
|
2024-10-24 16:35:51 -04:00
|
|
|
);
|
2023-05-19 12:33:56 -04:00
|
|
|
}
|