Download api/server/controllers/EndpointController.js from Zhitomir/chat: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/Zhitomir/chat/resolve/main/api/server/controllers/EndpointController.js
- Command line
-
hf download hf://spaces/Zhitomir/chat/api/server/controllers/EndpointController.js
-
curl -L -o EndpointController.js https://huggingface.co/spaces/Zhitomir/chat/resolve/main/api/server/controllers/EndpointController.js
1.83 kB
| 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.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, | |
| }; | |
| } | |
| const endpointsConfig = orderEndpointsConfig(mergedConfig); | |
| await cache.set(CacheKeys.ENDPOINT_CONFIG, endpointsConfig); | |
| res.send(JSON.stringify(endpointsConfig)); | |
| } | |
| module.exports = endpointController; | |