mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 19:26:54 +08:00
feat: finish basic functions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { OpenAIApi, Configuration } from "openai";
|
||||
import { apiKey } from "./config";
|
||||
import { ChatRequest } from "./typing";
|
||||
|
||||
// set up openai api client
|
||||
const config = new Configuration({
|
||||
@@ -7,17 +8,12 @@ const config = new Configuration({
|
||||
});
|
||||
const openai = new OpenAIApi(config);
|
||||
|
||||
export async function GET(req: Request) {
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
const requestBody = (await req.json()) as ChatRequest;
|
||||
const completion = await openai.createChatCompletion(
|
||||
{
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: "hello",
|
||||
},
|
||||
],
|
||||
model: "gpt-3.5-turbo",
|
||||
...requestBody,
|
||||
},
|
||||
{
|
||||
proxy: {
|
||||
|
@@ -1,3 +0,0 @@
|
||||
export async function GET(request: Request) {
|
||||
return new Response('Hello, Next.js!')
|
||||
}
|
Reference in New Issue
Block a user