mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00

* feat: send the LibreChat user ID as a query param when fetching the list of models * chore: update bun * chore: change bun command for building data-provider * refactor: prefer use of `getCustomConfig` to access custom config, also move to `server/services/Config` * refactor: make endpoints/custom option for the config optional, add userIdQuery, and use modelQueries log store in ModelService * refactor(ModelService): use env variables at runtime, use default models from data-provider, and add tests * docs: add `userIdQuery` * fix(ci): import changed
21 lines
747 B
JavaScript
21 lines
747 B
JavaScript
const { CacheKeys } = require('librechat-data-provider');
|
|
const { loadDefaultModels, loadConfigModels } = require('~/server/services/Config');
|
|
const { getLogStores } = require('~/cache');
|
|
|
|
async function modelController(req, res) {
|
|
const cache = getLogStores(CacheKeys.CONFIG_STORE);
|
|
const cachedModelsConfig = await cache.get(CacheKeys.MODELS_CONFIG);
|
|
if (cachedModelsConfig) {
|
|
res.send(cachedModelsConfig);
|
|
return;
|
|
}
|
|
const defaultModelsConfig = await loadDefaultModels(req);
|
|
const customModelsConfig = await loadConfigModels(req);
|
|
|
|
const modelConfig = { ...defaultModelsConfig, ...customModelsConfig };
|
|
|
|
await cache.set(CacheKeys.MODELS_CONFIG, modelConfig);
|
|
res.send(modelConfig);
|
|
}
|
|
|
|
module.exports = modelController;
|