This commit is contained in:
Aloxaf 2025-02-03 15:27:26 +08:00 committed by GitHub
commit 447cfde6f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 11 deletions

View File

@ -124,6 +124,11 @@ export async function requestOpenai(req: NextRequest) {
[ [
ServiceProvider.OpenAI, ServiceProvider.OpenAI,
ServiceProvider.Azure, ServiceProvider.Azure,
// 自定义等级
"L1",
"L2",
"L3",
"L4",
jsonBody?.model as string, // support provider-unspecified model jsonBody?.model as string, // support provider-unspecified model
], ],
) )

View File

@ -14,8 +14,11 @@ function getModels(remoteModelRes: OpenAIListModelResponse) {
if (config.disableGPT4) { if (config.disableGPT4) {
remoteModelRes.data = remoteModelRes.data.filter( remoteModelRes.data = remoteModelRes.data.filter(
(m) => (m) =>
!(m.id.startsWith("gpt-4") || m.id.startsWith("chatgpt-4o") || m.id.startsWith("o1")) || !(
m.id.startsWith("gpt-4o-mini"), m.id.startsWith("gpt-4") ||
m.id.startsWith("chatgpt-4o") ||
m.id.startsWith("o1")
) || m.id.startsWith("gpt-4o-mini"),
); );
} }

View File

@ -34,16 +34,16 @@ export async function handle(
}), }),
); );
// if dalle3 use openai api key // if dalle3 use openai api key
const baseUrl = req.headers.get("x-base-url"); const baseUrl = req.headers.get("x-base-url");
if (baseUrl?.includes("api.openai.com")) { if (baseUrl?.includes("api.openai.com")) {
if (!serverConfig.apiKey) { if (!serverConfig.apiKey) {
return NextResponse.json( return NextResponse.json(
{ error: "OpenAI API key not configured" }, { error: "OpenAI API key not configured" },
{ status: 500 }, { status: 500 },
); );
}
headers.set("Authorization", `Bearer ${serverConfig.apiKey}`);
} }
headers.set("Authorization", `Bearer ${serverConfig.apiKey}`);
}
const controller = new AbortController(); const controller = new AbortController();
const fetchOptions: RequestInit = { const fetchOptions: RequestInit = {

View File

@ -7,6 +7,7 @@ import RemarkGfm from "remark-gfm";
import RehypeHighlight from "rehype-highlight"; import RehypeHighlight from "rehype-highlight";
import { useRef, useState, RefObject, useEffect, useMemo } from "react"; import { useRef, useState, RefObject, useEffect, useMemo } from "react";
import { copyToClipboard, useWindowSize } from "../utils"; import { copyToClipboard, useWindowSize } from "../utils";
import "lowlight/lib/all";
import mermaid from "mermaid"; import mermaid from "mermaid";
import Locale from "../locales"; import Locale from "../locales";
import LoadingIcon from "../icons/three-dots.svg"; import LoadingIcon from "../icons/three-dots.svg";

View File

@ -36,6 +36,7 @@
"html-to-image": "^1.11.11", "html-to-image": "^1.11.11",
"idb-keyval": "^6.2.1", "idb-keyval": "^6.2.1",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"lowlight": "^2.0.0",
"markdown-to-txt": "^2.0.1", "markdown-to-txt": "^2.0.1",
"mermaid": "^10.6.1", "mermaid": "^10.6.1",
"nanoid": "^5.0.3", "nanoid": "^5.0.3",