Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛fix: wrong judgement on client fetch #2519

Merged
merged 5 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/(main)/settings/llm/Azure/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const AzureOpenAIProvider = memo(() => {
placeholder: t('azure.modelListPlaceholder'),
}}
provider={providerKey}
showBrowserRequest
title={
<Flexbox align={'center'} gap={8} horizontal>
<Azure.Combine size={22} type={'color'}></Azure.Combine>
Expand Down
30 changes: 29 additions & 1 deletion src/store/user/slices/settings/selectors/modelConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest';

import { UserStore } from '@/store/user';
import { merge } from '@/utils/merge';

import { UserStore, useUserStore } from '../../../store';
import { UserSettingsState, initialSettingsState } from '../initialState';
import { modelConfigSelectors } from './modelConfig';

Expand Down Expand Up @@ -33,6 +33,34 @@ describe('modelConfigSelectors', () => {
});
});

describe('isProviderFetchOnClient', () => {
it('client fetch should disabled on default', () => {
const s = merge(initialSettingsState, {
settings: {
languageModel: {
azure: {
endpoint: 'endpoint',
apiKey: 'apikey',
},
},
},
} as UserSettingsState) as unknown as UserStore;

expect(modelConfigSelectors.isProviderFetchOnClient('azure')(s)).toBe(false);
});

it('client fetch should enabled if user set it enabled', () => {
const s = merge(initialSettingsState, {
settings: {
languageModel: {
azure: { fetchOnClient: true },
},
},
} as UserSettingsState) as unknown as UserStore;
expect(modelConfigSelectors.isProviderFetchOnClient('azure')(s)).toBe(true);
});
});

describe('getCustomModelCardById', () => {
it('should return the custom model card with the given id and provider', () => {
const s = merge(initialSettingsState, {
Expand Down
2 changes: 1 addition & 1 deletion src/store/user/slices/settings/selectors/modelConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const isProviderFetchOnClient = (provider: GlobalLLMProviderKey | string) => (s:
const config = getProviderConfigById(provider)(s);
if (typeof config?.fetchOnClient !== 'undefined') return config?.fetchOnClient;

return isProviderEndpointNotEmpty(provider)(s);
return false;
};

const getCustomModelCard =
Expand Down
Loading