forked from danny-avila/LibreChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ refactor: Integrate Capabilities into Agent File Uploads and Tool H…
…andling (danny-avila#5048) * refactor: support drag/drop files for agents, handle undefined tool_resource edge cases * refactor: consolidate endpoints config logic to dedicated getter * refactor: Enhance agent tools loading logic to respect capabilities and filter tools accordingly * refactor: Integrate endpoint capabilities into file upload dropdown for dynamic resource handling * refactor: Implement capability checks for agent file upload operations * fix: non-image tool_resource check
- Loading branch information
1 parent
6109f0f
commit 291dc67
Showing
17 changed files
with
448 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const { CacheKeys, EModelEndpoint, orderEndpointsConfig } = require('librechat-data-provider'); | ||
const loadDefaultEndpointsConfig = require('./loadDefaultEConfig'); | ||
const loadConfigEndpoints = require('./loadConfigEndpoints'); | ||
const getLogStores = require('~/cache/getLogStores'); | ||
|
||
/** | ||
* | ||
* @param {ServerRequest} req | ||
* @returns {Promise<TEndpointsConfig>} | ||
*/ | ||
async function getEndpointsConfig(req) { | ||
const cache = getLogStores(CacheKeys.CONFIG_STORE); | ||
const cachedEndpointsConfig = await cache.get(CacheKeys.ENDPOINT_CONFIG); | ||
if (cachedEndpointsConfig) { | ||
return cachedEndpointsConfig; | ||
} | ||
|
||
const defaultEndpointsConfig = await loadDefaultEndpointsConfig(req); | ||
const customConfigEndpoints = await loadConfigEndpoints(req); | ||
|
||
/** @type {TEndpointsConfig} */ | ||
const mergedConfig = { ...defaultEndpointsConfig, ...customConfigEndpoints }; | ||
if (mergedConfig[EModelEndpoint.assistants] && req.app.locals?.[EModelEndpoint.assistants]) { | ||
const { disableBuilder, retrievalModels, capabilities, version, ..._rest } = | ||
req.app.locals[EModelEndpoint.assistants]; | ||
|
||
mergedConfig[EModelEndpoint.assistants] = { | ||
...mergedConfig[EModelEndpoint.assistants], | ||
version, | ||
retrievalModels, | ||
disableBuilder, | ||
capabilities, | ||
}; | ||
} | ||
if (mergedConfig[EModelEndpoint.agents] && req.app.locals?.[EModelEndpoint.agents]) { | ||
const { disableBuilder, capabilities, ..._rest } = req.app.locals[EModelEndpoint.agents]; | ||
|
||
mergedConfig[EModelEndpoint.agents] = { | ||
...mergedConfig[EModelEndpoint.agents], | ||
disableBuilder, | ||
capabilities, | ||
}; | ||
} | ||
|
||
if ( | ||
mergedConfig[EModelEndpoint.azureAssistants] && | ||
req.app.locals?.[EModelEndpoint.azureAssistants] | ||
) { | ||
const { disableBuilder, retrievalModels, capabilities, version, ..._rest } = | ||
req.app.locals[EModelEndpoint.azureAssistants]; | ||
|
||
mergedConfig[EModelEndpoint.azureAssistants] = { | ||
...mergedConfig[EModelEndpoint.azureAssistants], | ||
version, | ||
retrievalModels, | ||
disableBuilder, | ||
capabilities, | ||
}; | ||
} | ||
|
||
if (mergedConfig[EModelEndpoint.bedrock] && req.app.locals?.[EModelEndpoint.bedrock]) { | ||
const { availableRegions } = req.app.locals[EModelEndpoint.bedrock]; | ||
mergedConfig[EModelEndpoint.bedrock] = { | ||
...mergedConfig[EModelEndpoint.bedrock], | ||
availableRegions, | ||
}; | ||
} | ||
|
||
const endpointsConfig = orderEndpointsConfig(mergedConfig); | ||
|
||
await cache.set(CacheKeys.ENDPOINT_CONFIG, endpointsConfig); | ||
return endpointsConfig; | ||
} | ||
|
||
module.exports = { getEndpointsConfig }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.