Refactor: replace endpointsConfig recoil store with react query (#1085)

This commit is contained in:
Danny Avila 2023-10-21 13:50:29 -04:00 committed by GitHub
parent 7d6a1d260f
commit 4073b7d05d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 83 additions and 49 deletions

View file

@ -2,6 +2,7 @@ export * from './json';
export * from './languages';
export { default as cn } from './cn';
export { default as buildTree } from './buildTree';
export { default as mapEndpoints } from './mapEndpoints';
export { default as getLoginError } from './getLoginError';
export { default as cleanupPreset } from './cleanupPreset';
export { default as validateIframe } from './validateIframe';

View file

@ -0,0 +1,27 @@
import type { TEndpointsConfig } from 'librechat-data-provider';
const getEndpointsFilter = (config: TEndpointsConfig) => {
const filter: Record<string, boolean> = {};
for (const key of Object.keys(config)) {
filter[key] = !!config[key];
}
return filter;
};
const getAvailableEndpoints = (filter: Record<string, boolean>) => {
const endpoints = [
'azureOpenAI',
'openAI',
'chatGPTBrowser',
'gptPlugins',
'bingAI',
'google',
'anthropic',
];
return endpoints.filter((endpoint) => filter[endpoint]);
};
export default function mapEndpoints(config: TEndpointsConfig) {
const filter = getEndpointsFilter(config);
return getAvailableEndpoints(filter);
}