mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-06-16 07:51:32 +03:00
* fix token config tenant cache scope * fix token config scoped cache backfill * chore sort token config imports
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const { logger } = require('@librechat/data-schemas');
|
|
const { resolveTokenConfigMap } = require('@librechat/api');
|
|
const { getModelsConfig } = require('~/server/controllers/ModelController');
|
|
const { getValueKey, getMultiplier, getCacheMultiplier } = require('~/models');
|
|
|
|
/**
|
|
* Returns server-resolved context windows (and pricing when
|
|
* `interface.contextCost` is enabled) for every configured model. Resolution
|
|
* lives in `@librechat/api`; this controller only supplies request-scoped deps.
|
|
* @param {ServerRequest} req
|
|
* @param {ServerResponse} res
|
|
*/
|
|
async function tokenConfigController(req, res) {
|
|
try {
|
|
const modelsConfig = await getModelsConfig(req);
|
|
const tokenConfigMap = await resolveTokenConfigMap(
|
|
{
|
|
appConfig: req.config,
|
|
modelsConfig,
|
|
userId: req.user.id,
|
|
tenantId: req.user.tenantId,
|
|
},
|
|
{ getValueKey, getMultiplier, getCacheMultiplier },
|
|
);
|
|
res.json(tokenConfigMap);
|
|
} catch (error) {
|
|
logger.error('[tokenConfigController]', error);
|
|
res.status(500).json({ error: 'Failed to resolve token config' });
|
|
}
|
|
}
|
|
|
|
module.exports = tokenConfigController;
|