From 49fc75235a568ce44af735838ae4028e632689fa Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sat, 11 Mar 2023 22:35:38 +0800 Subject: [PATCH] feat: add log --- app/api/chat-stream/route.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/chat-stream/route.ts b/app/api/chat-stream/route.ts index b1bf0136..5caa61b2 100644 --- a/app/api/chat-stream/route.ts +++ b/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: ChatRequest) { +async function createStream(payload: string) { const encoder = new TextEncoder(); const decoder = new TextDecoder(); @@ -16,7 +16,7 @@ async function createStream(payload: ChatRequest) { Authorization: `Bearer ${apiKey}`, }, method: "POST", - body: JSON.stringify(payload), + body: payload, }); const stream = new ReadableStream({ @@ -51,7 +51,8 @@ async function createStream(payload: ChatRequest) { export async function POST(req: NextRequest) { try { - const body = (await req.json()) as ChatRequest; + console.log("Request", req); + const body = await req.text(); const stream = await createStream(body); return new Response(stream); } catch (error) {