mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 14:57:42 +00:00
⚙️ perf: reduce first-load MongoDB round trips (#14101)
* perf(api): reduce first-load database round trips * docs: move agent guidance to claude docs * refactor(api): move message validation into api package * fix(api): narrow active generation job lookup * fix(api): preserve omitted source identity
This commit is contained in:
parent
a0aa1f2b9d
commit
44d1275f36
25 changed files with 895 additions and 242 deletions
|
|
@ -5,6 +5,7 @@ const {
|
|||
needsRefresh,
|
||||
MCPOAuthHandler,
|
||||
MCPTokenStorage,
|
||||
getAppConfigOptionsFromUser,
|
||||
normalizeHttpError,
|
||||
extractWebSearchEnvVars,
|
||||
deleteAgentCheckpoints,
|
||||
|
|
@ -59,13 +60,7 @@ const sanitizeUserForResponse = (user) => {
|
|||
};
|
||||
|
||||
const getUserController = async (req, res) => {
|
||||
const appConfig =
|
||||
req.config ??
|
||||
(await getAppConfig({
|
||||
role: req.user?.role,
|
||||
userId: req.user?.id,
|
||||
tenantId: req.user?.tenantId,
|
||||
}));
|
||||
const appConfig = req.config ?? (await getAppConfig(getAppConfigOptionsFromUser(req.user)));
|
||||
/** @type {IUser} */
|
||||
const userData = sanitizeUserForResponse(req.user);
|
||||
if (appConfig.fileStrategy === FileSources.s3 && userData.avatar) {
|
||||
|
|
@ -203,13 +198,7 @@ const deleteUserMcpServers = async (userId) => {
|
|||
};
|
||||
|
||||
const updateUserPluginsController = async (req, res) => {
|
||||
const appConfig =
|
||||
req.config ??
|
||||
(await getAppConfig({
|
||||
role: req.user?.role,
|
||||
userId: req.user?.id,
|
||||
tenantId: req.user?.tenantId,
|
||||
}));
|
||||
const appConfig = req.config ?? (await getAppConfig(getAppConfigOptionsFromUser(req.user)));
|
||||
const { user } = req;
|
||||
const { pluginKey, action, auth, isEntityTool } = req.body;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,16 @@ jest.mock('@librechat/api', () => ({
|
|||
},
|
||||
normalizeHttpError: jest.fn((error) => error),
|
||||
extractWebSearchEnvVars: jest.fn((params) => params.keys),
|
||||
getAppConfigOptionsFromUser: jest.fn((user) => {
|
||||
const hasSourceIdentity =
|
||||
user != null && Object.prototype.hasOwnProperty.call(user, 'idOnTheSource');
|
||||
return {
|
||||
role: user?.role,
|
||||
userId: user?.id,
|
||||
idOnTheSource: user?.id && hasSourceIdentity ? (user.idOnTheSource ?? null) : undefined,
|
||||
tenantId: user?.tenantId,
|
||||
};
|
||||
}),
|
||||
needsRefresh: jest.fn(),
|
||||
getNewS3URL: jest.fn(),
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue