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