mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-18 05:18:31 +00:00
🐛 fix: fix tts in new provider model (#5569)
This commit is contained in:
+14
-3
@@ -4,6 +4,8 @@ import {
|
||||
OPENAI_API_KEY_HEADER_KEY,
|
||||
OPENAI_END_POINT,
|
||||
} from '@/const/fetch';
|
||||
import { isDeprecatedEdition } from '@/const/version';
|
||||
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
import { useUserStore } from '@/store/user';
|
||||
import { keyVaultsConfigSelectors } from '@/store/user/selectors';
|
||||
|
||||
@@ -14,14 +16,23 @@ import { keyVaultsConfigSelectors } from '@/store/user/selectors';
|
||||
// eslint-disable-next-line no-undef
|
||||
export const createHeaderWithOpenAI = (header?: HeadersInit): HeadersInit => {
|
||||
const state = useUserStore.getState();
|
||||
const openAIConfig = keyVaultsConfigSelectors.openAIConfig(state);
|
||||
|
||||
let keyVaults: Record<string, any> = {};
|
||||
|
||||
// TODO: remove this condition in V2.0
|
||||
if (isDeprecatedEdition) {
|
||||
keyVaults = keyVaultsConfigSelectors.getVaultByProvider('openai' as any)(
|
||||
useUserStore.getState(),
|
||||
);
|
||||
} else {
|
||||
keyVaults = aiProviderSelectors.providerKeyVaults('openai')(useAiInfraStore.getState()) || {};
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
return {
|
||||
...header,
|
||||
[LOBE_CHAT_ACCESS_CODE]: keyVaultsConfigSelectors.password(state),
|
||||
[LOBE_USER_ID]: state.user?.id || '',
|
||||
[OPENAI_API_KEY_HEADER_KEY]: openAIConfig.apiKey || '',
|
||||
[OPENAI_END_POINT]: openAIConfig.baseURL || '',
|
||||
[OPENAI_API_KEY_HEADER_KEY]: keyVaults.apiKey || '',
|
||||
[OPENAI_END_POINT]: keyVaults.baseURL || '',
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user