Browse Source

feat: update payload config

Yidadaa 2 years ago
parent
commit
1161adaa9f
1 changed files with 2 additions and 3 deletions
  1. 2 3
      app/api/chat-stream/route.ts

+ 2 - 3
app/api/chat-stream/route.ts

@@ -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);