🛠️ refactor: Model Loading and Custom Endpoint Error Handling (#1849)

* fix: handle non-assistant role ChatCompletionMessage error

* refactor(ModelController): decouple res.send from loading/caching models

* fix(custom/initializeClient): only fetch custom endpoint models if models.fetch is true

* refactor(validateModel): load models if modelsConfig is not yet cached

* docs: update on file upload rate limiting
This commit is contained in:
Danny Avila 2024-02-20 12:57:58 -05:00 committed by GitHub
parent 542494fad6
commit dd8038b375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 47 additions and 10 deletions

View file

@ -1,4 +1,5 @@
const { EModelEndpoint, CacheKeys, ViolationTypes } = require('librechat-data-provider');
const { loadModels } = require('~/server/controllers/ModelController');
const { logViolation, getLogStores } = require('~/cache');
const { handleError } = require('~/server/utils');
@ -17,7 +18,11 @@ const validateModel = async (req, res, next) => {
}
const cache = getLogStores(CacheKeys.CONFIG_STORE);
const modelsConfig = await cache.get(CacheKeys.MODELS_CONFIG);
let modelsConfig = await cache.get(CacheKeys.MODELS_CONFIG);
if (!modelsConfig) {
modelsConfig = await loadModels(req);
}
if (!modelsConfig) {
return handleError(res, { text: 'Models not loaded' });
}