Skip to content

Commit

Permalink
Remove hooks to use built-in initialMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
jgmurillo10 committed Aug 12, 2023
1 parent 754119a commit b333729
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/app/assistants/[id]/chat.tsx
Expand Up @@ -7,17 +7,11 @@ import type { Message } from 'ai/react';
import { LoginComponent } from '@/components/login';

export const Chat = ({ role }: { role: string; }) => {
const { messages, input, handleInputChange, handleSubmit, setMessages } = useChat();
const { messages, input, handleInputChange, handleSubmit, setMessages } = useChat({
initialMessages: [roles[role as keyof typeof roles] as Message],
});
const { data: session, status } = useSession();

useEffect(() => {
setMessages([roles[role as keyof typeof roles] as Message]);
}, []);

useEffect(() => {
console.log('>>>', {messages, role, roles})
}, [messages]);

if (status === 'loading') {
return <p>Loading...</p>
}
Expand Down

0 comments on commit b333729

Please sign in to comment.