Merge remote-tracking branch 'upstream/main' into merge

# Conflicts:
#	app/api/openai.ts
#	app/client/platforms/openai.ts
#	app/store/chat.ts
#	app/store/config.ts
This commit is contained in:
sijinhui
2024-10-09 17:57:25 +08:00
29 changed files with 418 additions and 139 deletions

View File

@@ -11,8 +11,7 @@ import { NextRequest, NextResponse } from "next/server";
import { auth } from "./auth";
import { requestOpenai } from "./common";
// const ALLOWED_PATH = new Set(Object.values({ ...OpenaiPath, ...AZURE_PATH }));
const ALLOWD_PATH = new Set(Object.values(OpenaiPath));
const ALLOWED_PATH = new Set(Object.values(OpenaiPath));
function getModels(remoteModelRes: OpenAIListModelResponse) {
const config = getServerSideConfig();
@@ -48,7 +47,7 @@ export async function handle(
const subpath = params.path.join("/");
if (!ALLOWD_PATH.has(subpath)) {
if (!ALLOWED_PATH.has(subpath)) {
console.log("[OpenAI Route] forbidden path ", subpath);
return NextResponse.json(
{
@@ -57,7 +56,7 @@ export async function handle(
},
{
status: 403,
},
} as any,
);
}
@@ -89,7 +88,7 @@ export async function handle(
const availableModels = getModels(resJson);
return NextResponse.json(availableModels, {
status: response.status,
});
} as any);
}
return response;