Add AI chat feature

This commit is contained in:
James Blair 2026-05-08 20:24:34 +12:00
parent 80056b3728
commit 6a5041be43
Signed by: james
SSH key fingerprint: SHA256:hsDR3ENI2ZMgh+CNb+0PrFsj29DI007R+BMKUVGi6zQ
15 changed files with 1259 additions and 2 deletions

24
components/chat/index.tsx Normal file
View file

@ -0,0 +1,24 @@
"use client";
import { ChatMessages } from "./chat-messages";
import { ChatForm } from "./chat-form";
import { DefaultChatTransport } from "ai";
import { useChat } from "@ai-sdk/react";
export function Chat() {
const { messages, sendMessage, status, error } = useChat({
transport: new DefaultChatTransport({
api: "http://localhost:3000/api/chat",
}),
});
return (
<div className="max-w-2xl flex flex-col gap-2">
<ChatMessages messages={messages} />
<ChatForm
onMessage={sendMessage}
disabled={status === "submitted" || status === "streaming"}
/>
</div>
);
}