Skip to content

Commit 3fef83e

Browse files
authored
🐛 fix: fix tts in new provider model (#5569)
1 parent 8f7d907 commit 3fef83e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: src/services/_header.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
OPENAI_API_KEY_HEADER_KEY,
55
OPENAI_END_POINT,
66
} from '@/const/fetch';
7+
import { isDeprecatedEdition } from '@/const/version';
8+
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
79
import { useUserStore } from '@/store/user';
810
import { keyVaultsConfigSelectors } from '@/store/user/selectors';
911

@@ -14,14 +16,23 @@ import { keyVaultsConfigSelectors } from '@/store/user/selectors';
1416
// eslint-disable-next-line no-undef
1517
export const createHeaderWithOpenAI = (header?: HeadersInit): HeadersInit => {
1618
const state = useUserStore.getState();
17-
const openAIConfig = keyVaultsConfigSelectors.openAIConfig(state);
1819

20+
let keyVaults: Record<string, any> = {};
21+
22+
// TODO: remove this condition in V2.0
23+
if (isDeprecatedEdition) {
24+
keyVaults = keyVaultsConfigSelectors.getVaultByProvider('openai' as any)(
25+
useUserStore.getState(),
26+
);
27+
} else {
28+
keyVaults = aiProviderSelectors.providerKeyVaults('openai')(useAiInfraStore.getState()) || {};
29+
}
1930
// eslint-disable-next-line no-undef
2031
return {
2132
...header,
2233
[LOBE_CHAT_ACCESS_CODE]: keyVaultsConfigSelectors.password(state),
2334
[LOBE_USER_ID]: state.user?.id || '',
24-
[OPENAI_API_KEY_HEADER_KEY]: openAIConfig.apiKey || '',
25-
[OPENAI_END_POINT]: openAIConfig.baseURL || '',
35+
[OPENAI_API_KEY_HEADER_KEY]: keyVaults.apiKey || '',
36+
[OPENAI_END_POINT]: keyVaults.baseURL || '',
2637
};
2738
};

0 commit comments

Comments
 (0)