fix: vercel
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"use client";
|
||||
import { useChat } from "@ai-sdk/react";
|
||||
|
||||
export default function Chat() {
|
||||
const { messages, input, handleInputChange, handleSubmit } = useChat();
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2 max-h-[60vh] overflow-y-auto rounded border p-3">
|
||||
{messages.map((m) => (
|
||||
<div key={m.id} className={m.role === "user" ? "text-right" : ""}>
|
||||
<span className="inline-block rounded-lg bg-zinc-100 px-3 py-2 text-sm">{m.content}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<form onSubmit={handleSubmit} className="flex gap-2">
|
||||
<input value={input} onChange={handleInputChange} className="flex-1 rounded border p-2" placeholder="Stel een vraag..." />
|
||||
<button className="rounded bg-blue-600 px-4 py-2 text-white">Verstuur</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { streamText, convertToModelMessages } from "ai";
|
||||
import { openai } from "@ai-sdk/openai";
|
||||
import { createSupabaseServerClient } from "@/lib/supabase-server";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const { messages } = await req.json();
|
||||
const supabase = await createSupabaseServerClient();
|
||||
const { data: bands } = await supabase.from("bands").select("name, genre, country, stage, time");
|
||||
const context = (bands ?? []).map((b) => `${b.name} (${b.genre}, ${b.country}) — ${b.stage} ${b.time}`).join("\n");
|
||||
|
||||
const result = streamText({
|
||||
model: openai("gpt-4o-mini"),
|
||||
system: `Je bent een hulpvaardige festival-roadie voor Polderfest 2027.\nLine-up:\n${context}`,
|
||||
messages: convertToModelMessages(messages),
|
||||
});
|
||||
return result.toUIMessageStreamResponse();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@import 'tailwindcss';
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { Metadata } from "next";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = { title: "Polderfest 2027", description: "Polderfest 2027" };
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="nl">
|
||||
<body className="min-h-screen bg-white text-zinc-900 antialiased">
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import Chat from "./Chat";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<main className="mx-auto max-w-2xl p-8">
|
||||
<h1 className="text-4xl font-bold mb-2">Polderfest 2027</h1>
|
||||
<p className="text-zinc-600 mb-6">Stel vragen over de 500 bands van het festival.</p>
|
||||
<Chat />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user