2025-10-05 06:37:57 -04:00
|
|
|
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';
|
2025-08-26 12:10:18 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads custom config endpoints
|
2025-10-05 06:37:57 -04:00
|
|
|
* @param [config]
|
|
|
|
|
* @param [agentsDefaults]
|
2025-08-26 12:10:18 -04:00
|
|
|
*/
|
2025-10-05 06:37:57 -04:00
|
|
|
export const loadEndpoints = (
|
|
|
|
|
config: Partial<TCustomConfig>,
|
|
|
|
|
agentsDefaults?: Partial<TAgentsEndpoint>,
|
|
|
|
|
) => {
|
|
|
|
|
const loadedEndpoints: AppConfig['endpoints'] = {};
|
2025-08-26 12:10:18 -04:00
|
|
|
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) => {
|
2025-10-05 06:37:57 -04:00
|
|
|
const currentKey = key as keyof typeof endpoints;
|
|
|
|
|
if (endpoints?.[currentKey]) {
|
|
|
|
|
loadedEndpoints[currentKey] = endpoints[currentKey];
|
2025-08-26 12:10:18 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (endpoints?.all) {
|
|
|
|
|
loadedEndpoints.all = endpoints.all;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return loadedEndpoints;
|
|
|
|
|
};
|