feat: finish basic functions

This commit is contained in:
Yidadaa
2023-03-11 02:25:33 +08:00
parent 9912762157
commit 2c9baa4e2c
17 changed files with 2234 additions and 189 deletions

View File

@@ -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: {

View File

@@ -1,3 +0,0 @@
export async function GET(request: Request) {
return new Response('Hello, Next.js!')
}