forked from XiaoMo/ChatGPT-Next-Web
feat: update payload config
This commit is contained in:
parent
49fc75235a
commit
1161adaa9f
@ -4,7 +4,7 @@ import { NextRequest } from "next/server";
|
|||||||
|
|
||||||
const apiKey = process.env.OPENAI_API_KEY;
|
const apiKey = process.env.OPENAI_API_KEY;
|
||||||
|
|
||||||
async function createStream(payload: string) {
|
async function createStream(payload: ReadableStream<Uint8Array>) {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
|
|
||||||
@ -52,8 +52,7 @@ async function createStream(payload: string) {
|
|||||||
export async function POST(req: NextRequest) {
|
export async function POST(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
console.log("Request", req);
|
console.log("Request", req);
|
||||||
const body = await req.text();
|
const stream = await createStream(req.body!);
|
||||||
const stream = await createStream(body);
|
|
||||||
return new Response(stream);
|
return new Response(stream);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user