mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-24 22:50:22 +09:00
fix: USE_OPENAI_ENDPOINT_FOR_ALL_MODELS
This commit is contained in:
parent
c289305b05
commit
740ece39da
@ -300,7 +300,7 @@ anthropic claude Api Url.
|
||||
配置 Edge TTS 使用的语音声音,默认为:zh-CN-YunxiNeural
|
||||
可访问 https://learn.microsoft.com/zh-cn/azure/ai-services/speech-service/language-support?tabs=tts#supported-languages 查看支持的参数
|
||||
|
||||
### `NEXT_PUBLIC_USE_OPENAI_ENDPOINT_FOR_ALL_MODELS` (可选)
|
||||
### `USE_OPENAI_ENDPOINT_FOR_ALL_MODELS` (可选)
|
||||
|
||||
配置所有模型都使用 OpenAI 路由,在使用类似 `one-api` 的中转项目时会很有用
|
||||
将此环境变量设置为 1 即可
|
||||
|
@ -16,6 +16,7 @@ const DANGER_CONFIG = {
|
||||
isEnableRAG: serverConfig.isEnableRAG,
|
||||
defaultModel: serverConfig.defaultModel,
|
||||
edgeTTSVoiceName: serverConfig.edgeTTSVoiceName,
|
||||
isUseOpenAIEndpointForAllModels: serverConfig.isUseOpenAIEndpointForAllModels,
|
||||
};
|
||||
|
||||
declare global {
|
||||
|
@ -218,7 +218,7 @@ export function getHeaders(ignoreHeaders?: boolean) {
|
||||
const modelConfig = useChatStore.getState().currentSession().mask.modelConfig;
|
||||
const isGoogle =
|
||||
modelConfig.model.startsWith("gemini") &&
|
||||
!!!process.env.NEXT_PUBLIC_USE_OPENAI_ENDPOINT_FOR_ALL_MODELS;
|
||||
!accessStore.useOpenAIEndpointForAllModels();
|
||||
if (!ignoreHeaders && !isGoogle) {
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -153,5 +153,7 @@ export const getServerSideConfig = () => {
|
||||
allowedWebDevEndpoints,
|
||||
|
||||
edgeTTSVoiceName: process.env.EDGE_TTS_VOICE_NAME ?? "zh-CN-YunxiNeural",
|
||||
isUseOpenAIEndpointForAllModels:
|
||||
!!process.env.USE_OPENAI_ENDPOINT_FOR_ALL_MODELS,
|
||||
};
|
||||
};
|
||||
|
@ -54,6 +54,8 @@ const DEFAULT_ACCESS_STATE = {
|
||||
|
||||
// tts config
|
||||
edgeTTSVoiceName: "zh-CN-YunxiNeural",
|
||||
|
||||
isUseOpenAIEndpointForAllModels: false,
|
||||
};
|
||||
|
||||
export const useAccessStore = createPersistStore(
|
||||
@ -66,6 +68,12 @@ export const useAccessStore = createPersistStore(
|
||||
return get().needCode;
|
||||
},
|
||||
|
||||
useOpenAIEndpointForAllModels() {
|
||||
this.fetch();
|
||||
|
||||
return get().isUseOpenAIEndpointForAllModels;
|
||||
},
|
||||
|
||||
edgeVoiceName() {
|
||||
this.fetch();
|
||||
|
||||
|
@ -4,6 +4,7 @@ import Locale from "./locales";
|
||||
import { ClientApi, RequestMessage } from "./client/api";
|
||||
import { DEFAULT_MODELS, ModelProvider } from "./constant";
|
||||
import { identifyDefaultClaudeModel } from "./utils/checkers";
|
||||
import { useAccessStore } from "./store";
|
||||
|
||||
export function trimTopic(topic: string) {
|
||||
// Fix an issue where double quotes still show in the Indonesian language
|
||||
@ -282,7 +283,8 @@ export function isSupportRAGModel(modelName: string) {
|
||||
}
|
||||
|
||||
export function getClientApi(modelName: string): ClientApi {
|
||||
if (!!process.env.NEXT_PUBLIC_USE_OPENAI_ENDPOINT_FOR_ALL_MODELS)
|
||||
const accessStore = useAccessStore.getState();
|
||||
if (accessStore.useOpenAIEndpointForAllModels())
|
||||
return new ClientApi(ModelProvider.GPT);
|
||||
var api: ClientApi;
|
||||
if (modelName.startsWith("gemini")) {
|
||||
|
Loading…
Reference in New Issue
Block a user