From 4cc58c8346b9fa719c4c1f452b4dd2182cf8e7b4 Mon Sep 17 00:00:00 2001 From: shinework Date: Sun, 8 Oct 2023 11:30:17 +0200 Subject: [PATCH] fix: remove useless endpoint --- src/app/api/chat/route.ts | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/app/api/chat/route.ts diff --git a/src/app/api/chat/route.ts b/src/app/api/chat/route.ts deleted file mode 100644 index f49e97a..0000000 --- a/src/app/api/chat/route.ts +++ /dev/null @@ -1,26 +0,0 @@ -import OpenAI from 'openai'; -import { OpenAIStream, StreamingTextResponse } from 'ai'; - -// Create an OpenAI API client (that's edge friendly!) -const openai = new OpenAI({ - apiKey: process.env.OPENAI_API_KEY!, -}); - -// IMPORTANT! Set the runtime to edge -export const runtime = 'edge'; - -export async function POST(req: Request) { - // Extract the `messages` from the body of the request - const { messages } = await req.json(); - - // Ask OpenAI for a streaming chat completion given the prompt - const response = await openai.chat.completions.create({ - model: 'gpt-3.5-turbo', - stream: true, - messages, - }); - // Convert the response into a friendly text-stream - const stream = OpenAIStream(response); - // Respond with the stream - return new StreamingTextResponse(stream); -}