mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* feat: CONFIG_VERSION v1.1.9, agents config * refactor: Assistants Code Interpreter Toggle Improved Accessibility * feat: Agents Config
70 lines
2.4 KiB
JavaScript
70 lines
2.4 KiB
JavaScript
const { CacheKeys, EModelEndpoint, orderEndpointsConfig } = require('librechat-data-provider');
|
|
const { loadDefaultEndpointsConfig, loadConfigEndpoints } = require('~/server/services/Config');
|
|
const { getLogStores } = require('~/cache');
|
|
|
|
async function endpointController(req, res) {
|
|
const cache = getLogStores(CacheKeys.CONFIG_STORE);
|
|
const cachedEndpointsConfig = await cache.get(CacheKeys.ENDPOINT_CONFIG);
|
|
if (cachedEndpointsConfig) {
|
|
res.send(cachedEndpointsConfig);
|
|
return;
|
|
}
|
|
|
|
const defaultEndpointsConfig = await loadDefaultEndpointsConfig(req);
|
|
const customConfigEndpoints = await loadConfigEndpoints(req);
|
|
|
|
/** @type {TEndpointsConfig} */
|
|
const mergedConfig = { ...defaultEndpointsConfig, ...customConfigEndpoints };
|
|
if (mergedConfig[EModelEndpoint.assistants] && req.app.locals?.[EModelEndpoint.assistants]) {
|
|
const { disableBuilder, retrievalModels, capabilities, version, ..._rest } =
|
|
req.app.locals[EModelEndpoint.assistants];
|
|
|
|
mergedConfig[EModelEndpoint.assistants] = {
|
|
...mergedConfig[EModelEndpoint.assistants],
|
|
version,
|
|
retrievalModels,
|
|
disableBuilder,
|
|
capabilities,
|
|
};
|
|
}
|
|
if (mergedConfig[EModelEndpoint.agents] && req.app.locals?.[EModelEndpoint.agents]) {
|
|
const { disableBuilder, capabilities, ..._rest } = req.app.locals[EModelEndpoint.agents];
|
|
|
|
mergedConfig[EModelEndpoint.agents] = {
|
|
...mergedConfig[EModelEndpoint.agents],
|
|
disableBuilder,
|
|
capabilities,
|
|
};
|
|
}
|
|
|
|
if (
|
|
mergedConfig[EModelEndpoint.azureAssistants] &&
|
|
req.app.locals?.[EModelEndpoint.azureAssistants]
|
|
) {
|
|
const { disableBuilder, retrievalModels, capabilities, version, ..._rest } =
|
|
req.app.locals[EModelEndpoint.azureAssistants];
|
|
|
|
mergedConfig[EModelEndpoint.azureAssistants] = {
|
|
...mergedConfig[EModelEndpoint.azureAssistants],
|
|
version,
|
|
retrievalModels,
|
|
disableBuilder,
|
|
capabilities,
|
|
};
|
|
}
|
|
|
|
if (mergedConfig[EModelEndpoint.bedrock] && req.app.locals?.[EModelEndpoint.bedrock]) {
|
|
const { availableRegions } = req.app.locals[EModelEndpoint.bedrock];
|
|
mergedConfig[EModelEndpoint.bedrock] = {
|
|
...mergedConfig[EModelEndpoint.bedrock],
|
|
availableRegions,
|
|
};
|
|
}
|
|
|
|
const endpointsConfig = orderEndpointsConfig(mergedConfig);
|
|
|
|
await cache.set(CacheKeys.ENDPOINT_CONFIG, endpointsConfig);
|
|
res.send(JSON.stringify(endpointsConfig));
|
|
}
|
|
|
|
module.exports = endpointController;
|