Authenticate /api/generate

This commit is contained in:
Jared Palmer 2023-05-22 10:21:51 -04:00
parent a46b2ac3c6
commit 5f60a8ab35

View file

@ -1,10 +1,12 @@
import { auth } from "@/auth";
import { OpenAIStream, openai } from "@/lib/openai";
import { getServerSession } from "@/lib/session/get-server-session";
import { prisma } from "@/lib/prisma";
export async function POST(req: Request) {
export const runtime = "edge";
export const POST = auth(async function POST(req: Request) {
const json = await req.json();
const session = await getServerSession();
console.log(req.auth);
const res = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
@ -41,4 +43,4 @@ export async function POST(req: Request) {
status: 200,
headers: { "Content-Type": "text/event-stream" },
});
}
});