mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-25 11:46:12 +01:00
* chore: linting for `loadCustomConfig` * refactor: decouple CDN init and variable/health checks from AppService * refactor: move AppService to packages/data-schemas * chore: update AppConfig import path to use data-schemas * chore: update JsonSchemaType import path to use data-schemas * refactor: update UserController to import webSearchKeys and redefine FunctionTool typedef * chore: remove AppService.js * refactor: update AppConfig interface to use Partial<TCustomConfig> and make paths and fileStrategies optional * refactor: update checkConfig function to accept Partial<TCustomConfig> * chore: fix types * refactor: move handleRateLimits to startup checks as is an effect * test: remove outdated rate limit tests from AppService.spec and add new handleRateLimits tests in checks.spec
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import { EModelEndpoint } from 'librechat-data-provider';
|
|
import type { TCustomConfig, TAgentsEndpoint } from 'librechat-data-provider';
|
|
import type { AppConfig } from '~/types';
|
|
import { azureAssistantsDefaults, assistantsConfigSetup } from './assistants';
|
|
import { agentsConfigSetup } from './agents';
|
|
import { azureConfigSetup } from './azure';
|
|
|
|
/**
|
|
* Loads custom config endpoints
|
|
* @param [config]
|
|
* @param [agentsDefaults]
|
|
*/
|
|
export const loadEndpoints = (
|
|
config: Partial<TCustomConfig>,
|
|
agentsDefaults?: Partial<TAgentsEndpoint>,
|
|
) => {
|
|
const loadedEndpoints: AppConfig['endpoints'] = {};
|
|
const endpoints = config?.endpoints;
|
|
|
|
if (endpoints?.[EModelEndpoint.azureOpenAI]) {
|
|
loadedEndpoints[EModelEndpoint.azureOpenAI] = azureConfigSetup(config);
|
|
}
|
|
|
|
if (endpoints?.[EModelEndpoint.azureOpenAI]?.assistants) {
|
|
loadedEndpoints[EModelEndpoint.azureAssistants] = azureAssistantsDefaults();
|
|
}
|
|
|
|
if (endpoints?.[EModelEndpoint.azureAssistants]) {
|
|
loadedEndpoints[EModelEndpoint.azureAssistants] = assistantsConfigSetup(
|
|
config,
|
|
EModelEndpoint.azureAssistants,
|
|
loadedEndpoints[EModelEndpoint.azureAssistants],
|
|
);
|
|
}
|
|
|
|
if (endpoints?.[EModelEndpoint.assistants]) {
|
|
loadedEndpoints[EModelEndpoint.assistants] = assistantsConfigSetup(
|
|
config,
|
|
EModelEndpoint.assistants,
|
|
loadedEndpoints[EModelEndpoint.assistants],
|
|
);
|
|
}
|
|
|
|
loadedEndpoints[EModelEndpoint.agents] = agentsConfigSetup(config, agentsDefaults);
|
|
|
|
const endpointKeys = [
|
|
EModelEndpoint.openAI,
|
|
EModelEndpoint.google,
|
|
EModelEndpoint.custom,
|
|
EModelEndpoint.bedrock,
|
|
EModelEndpoint.anthropic,
|
|
];
|
|
|
|
endpointKeys.forEach((key) => {
|
|
const currentKey = key as keyof typeof endpoints;
|
|
if (endpoints?.[currentKey]) {
|
|
loadedEndpoints[currentKey] = endpoints[currentKey];
|
|
}
|
|
});
|
|
|
|
if (endpoints?.all) {
|
|
loadedEndpoints.all = endpoints.all;
|
|
}
|
|
|
|
return loadedEndpoints;
|
|
};
|