mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 16:15:50 +08:00
feat: add basic ui
This commit is contained in:
1
app/api/chat/.gitignore
vendored
Normal file
1
app/api/chat/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
config.ts
|
35
app/api/chat/route.ts
Normal file
35
app/api/chat/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { OpenAIApi, Configuration } from "openai";
|
||||
import { apiKey } from "./config";
|
||||
|
||||
// set up openai api client
|
||||
const config = new Configuration({
|
||||
apiKey,
|
||||
});
|
||||
const openai = new OpenAIApi(config);
|
||||
|
||||
export async function GET(req: Request) {
|
||||
try {
|
||||
const completion = await openai.createChatCompletion(
|
||||
{
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: "hello",
|
||||
},
|
||||
],
|
||||
model: "gpt-3.5-turbo",
|
||||
},
|
||||
{
|
||||
proxy: {
|
||||
protocol: "socks",
|
||||
host: "127.0.0.1",
|
||||
port: 7890,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return new Response(JSON.stringify(completion.data));
|
||||
} catch (e) {
|
||||
return new Response(JSON.stringify(e));
|
||||
}
|
||||
}
|
7
app/api/chat/typing.ts
Normal file
7
app/api/chat/typing.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type {
|
||||
CreateChatCompletionRequest,
|
||||
CreateChatCompletionResponse,
|
||||
} from "openai";
|
||||
|
||||
export type ChatRequest = CreateChatCompletionRequest;
|
||||
export type ChatReponse = CreateChatCompletionResponse;
|
Reference in New Issue
Block a user