mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-27 21:58:51 +01:00
Refactor: replace endpointsConfig recoil store with react query (#1085)
This commit is contained in:
parent
7d6a1d260f
commit
4073b7d05d
15 changed files with 83 additions and 49 deletions
|
|
@ -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';
|
||||
|
|
|
|||
27
client/src/utils/mapEndpoints.ts
Normal file
27
client/src/utils/mapEndpoints.ts
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue