mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 19:30:15 +01:00
refactor: replace getMCPAuthMap with getUserMCPAuthMap and remove unused getCustomConfig file
This commit is contained in:
parent
71a14517cd
commit
c0d6404385
3 changed files with 5 additions and 37 deletions
|
|
@ -8,6 +8,7 @@ const {
|
|||
Tokenizer,
|
||||
checkAccess,
|
||||
hasCustomUserVars,
|
||||
getUserMCPAuthMap,
|
||||
memoryInstructions,
|
||||
formatContentStrings,
|
||||
createMemoryProcessor,
|
||||
|
|
@ -40,10 +41,10 @@ const {
|
|||
deleteMemory,
|
||||
setMemory,
|
||||
} = require('~/models');
|
||||
const { checkCapability, getMCPAuthMap, getAppConfig } = require('~/server/services/Config');
|
||||
const { addCacheControl, createContextHandlers } = require('~/app/clients/prompts');
|
||||
const { initializeAgent } = require('~/server/services/Endpoints/agents/agent');
|
||||
const { spendTokens, spendStructuredTokens } = require('~/models/spendTokens');
|
||||
const { checkCapability, getAppConfig } = require('~/server/services/Config');
|
||||
const { encodeAndFormat } = require('~/server/services/Files/images/encode');
|
||||
const { getProviderConfig } = require('~/server/services/Endpoints');
|
||||
const BaseClient = require('~/app/clients/BaseClient');
|
||||
|
|
@ -913,10 +914,10 @@ class AgentClient extends BaseClient {
|
|||
}
|
||||
|
||||
try {
|
||||
if (hasCustomUserVars(appConfig)) {
|
||||
config.configurable.userMCPAuthMap = await getMCPAuthMap({
|
||||
tools: agent.tools,
|
||||
if (agent.tools?.length && hasCustomUserVars(appConfig)) {
|
||||
config.configurable.userMCPAuthMap = await getUserMCPAuthMap({
|
||||
userId: this.options.req.user.id,
|
||||
tools: agent.tools,
|
||||
findPluginAuthsByKeys,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
const { logger } = require('@librechat/data-schemas');
|
||||
const { getUserMCPAuthMap } = require('@librechat/api');
|
||||
|
||||
/**
|
||||
* @param {Object} params
|
||||
* @param {string} params.userId
|
||||
* @param {GenericTool[]} [params.tools]
|
||||
* @param {import('@librechat/data-schemas').PluginAuthMethods['findPluginAuthsByKeys']} params.findPluginAuthsByKeys
|
||||
* @returns {Promise<Record<string, Record<string, string>> | undefined>}
|
||||
*/
|
||||
async function getMCPAuthMap({ userId, tools, findPluginAuthsByKeys }) {
|
||||
try {
|
||||
if (!tools || tools.length === 0) {
|
||||
return;
|
||||
}
|
||||
return await getUserMCPAuthMap({
|
||||
tools,
|
||||
userId,
|
||||
findPluginAuthsByKeys,
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
`[api/server/controllers/agents/client.js #chatCompletion] Error getting custom user vars for agent`,
|
||||
err,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getMCPAuthMap,
|
||||
};
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
const appConfig = require('./app');
|
||||
const { config } = require('./EndpointService');
|
||||
const getCachedTools = require('./getCachedTools');
|
||||
const getCustomConfig = require('./getCustomConfig');
|
||||
const loadCustomConfig = require('./loadCustomConfig');
|
||||
const loadConfigModels = require('./loadConfigModels');
|
||||
const loadDefaultModels = require('./loadDefaultModels');
|
||||
|
|
@ -18,6 +17,5 @@ module.exports = {
|
|||
loadAsyncEndpoints,
|
||||
...appConfig,
|
||||
...getCachedTools,
|
||||
...getCustomConfig,
|
||||
...getEndpointsConfig,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue