feat: update payload config

This commit is contained in:
Yidadaa 2023-03-11 22:43:15 +08:00
parent 49fc75235a
commit 1161adaa9f
1 changed files with 2 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import { NextRequest } from "next/server";
const apiKey = process.env.OPENAI_API_KEY;
async function createStream(payload: string) {
async function createStream(payload: ReadableStream<Uint8Array>) {
const encoder = new TextEncoder();
const decoder = new TextDecoder();
@ -52,8 +52,7 @@ async function createStream(payload: string) {
export async function POST(req: NextRequest) {
try {
console.log("Request", req);
const body = await req.text();
const stream = await createStream(body);
const stream = await createStream(req.body!);
return new Response(stream);
} catch (error) {
console.error(error);