"use client" import { DefaultChatTransport } from "ai" import { useChat } from "@ai-sdk/react" import { useState } from "react" export default function Page() { const [input, setInput] = useState("") const { messages, sendMessage, status } = useChat({ // @ts-expect-error - Type mismatch between ai and @ai-sdk/react versions transport: new DefaultChatTransport({ api: "/api/stream", }), }) return (
{/* Header */}

Chat App

Chat with AI using Supermemory

{/* Messages Container */}
{messages.length === 0 && (
Start a conversation by typing a message below
)} {messages.map((message, index) => (
{message.role}
{message.parts.map((part) => { if (part.type === "text") { return
{part.text}
} return null })}
))} {status === "streaming" && (
AI is thinking...
)}
{/* Input Container */}
setInput(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter" && !event.shiftKey) { event.preventDefault() sendMessage({ parts: [{ type: "text", text: input }], }) } }} placeholder="Type your message here..." disabled={status === "streaming"} className="flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-background text-foreground placeholder:text-muted-foreground disabled:opacity-50 disabled:cursor-not-allowed" />
) }