next-enterprise/components/Chat/Chat.tsx

24 lines
480 B
TypeScript
Raw Normal View History

2023-08-11 17:21:43 +02:00
"use client"
import { useChat } from "ai/react"
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChat()
return (
<div>
{messages.map((m) => (
<div key={m.id}>
{m.role}: {m.content}
</div>
))}
<form onSubmit={handleSubmit}>
<label>
Say something...
<input value={input} onChange={handleInputChange} />
</label>
</form>
</div>
)
}