diff --git a/app/api/common.ts b/app/api/common.ts index b7e41fa26..25d82040e 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -124,6 +124,11 @@ export async function requestOpenai(req: NextRequest) { [ ServiceProvider.OpenAI, ServiceProvider.Azure, + // 自定义等级 + "L1", + "L2", + "L3", + "L4", jsonBody?.model as string, // support provider-unspecified model ], ) diff --git a/app/api/openai.ts b/app/api/openai.ts index 2b5deca8b..7be7994d0 100644 --- a/app/api/openai.ts +++ b/app/api/openai.ts @@ -14,8 +14,11 @@ function getModels(remoteModelRes: OpenAIListModelResponse) { if (config.disableGPT4) { remoteModelRes.data = remoteModelRes.data.filter( (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"), ); } diff --git a/app/api/proxy.ts b/app/api/proxy.ts index b3e5e7b7b..d75db84b6 100644 --- a/app/api/proxy.ts +++ b/app/api/proxy.ts @@ -34,16 +34,16 @@ export async function handle( }), ); // if dalle3 use openai api key - const baseUrl = req.headers.get("x-base-url"); - if (baseUrl?.includes("api.openai.com")) { - if (!serverConfig.apiKey) { - return NextResponse.json( - { error: "OpenAI API key not configured" }, - { status: 500 }, - ); - } - headers.set("Authorization", `Bearer ${serverConfig.apiKey}`); + const baseUrl = req.headers.get("x-base-url"); + if (baseUrl?.includes("api.openai.com")) { + if (!serverConfig.apiKey) { + return NextResponse.json( + { error: "OpenAI API key not configured" }, + { status: 500 }, + ); } + headers.set("Authorization", `Bearer ${serverConfig.apiKey}`); + } const controller = new AbortController(); const fetchOptions: RequestInit = { diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index ba85f0970..aa4deb8e3 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -7,6 +7,7 @@ import RemarkGfm from "remark-gfm"; import RehypeHighlight from "rehype-highlight"; import { useRef, useState, RefObject, useEffect, useMemo } from "react"; import { copyToClipboard, useWindowSize } from "../utils"; +import "lowlight/lib/all"; import mermaid from "mermaid"; import Locale from "../locales"; import LoadingIcon from "../icons/three-dots.svg"; diff --git a/package.json b/package.json index 0efe27b39..1d986e788 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "html-to-image": "^1.11.11", "idb-keyval": "^6.2.1", "lodash-es": "^4.17.21", + "lowlight": "^2.0.0", "markdown-to-txt": "^2.0.1", "mermaid": "^10.6.1", "nanoid": "^5.0.3",