2024-04-19 12:05:39 -04:00
|
|
|
const {
|
|
|
|
|
Capabilities,
|
|
|
|
|
EModelEndpoint,
|
|
|
|
|
assistantEndpointSchema,
|
|
|
|
|
} = require('librechat-data-provider');
|
|
|
|
|
const { logger } = require('~/config');
|
|
|
|
|
|
2024-04-19 19:05:25 -04:00
|
|
|
/**
|
|
|
|
|
* Sets up the minimum, default Assistants configuration if Azure OpenAI Assistants option is enabled.
|
|
|
|
|
* @returns {Partial<TAssistantEndpoint>} The Assistants endpoint configuration.
|
|
|
|
|
*/
|
|
|
|
|
function azureAssistantsDefaults() {
|
|
|
|
|
return {
|
|
|
|
|
capabilities: [Capabilities.tools, Capabilities.actions, Capabilities.code_interpreter],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 12:05:39 -04:00
|
|
|
/**
|
|
|
|
|
* Sets up the Assistants configuration from the config (`librechat.yaml`) file.
|
|
|
|
|
* @param {TCustomConfig} config - The loaded custom configuration.
|
2024-04-19 19:05:25 -04:00
|
|
|
* @param {Partial<TAssistantEndpoint>} [prevConfig]
|
|
|
|
|
* - The previously loaded assistants configuration from Azure OpenAI Assistants option.
|
2024-04-19 12:05:39 -04:00
|
|
|
* @returns {Partial<TAssistantEndpoint>} The Assistants endpoint configuration.
|
|
|
|
|
*/
|
2024-04-19 19:05:25 -04:00
|
|
|
function assistantsConfigSetup(config, prevConfig = {}) {
|
2024-04-19 12:05:39 -04:00
|
|
|
const assistantsConfig = config.endpoints[EModelEndpoint.assistants];
|
|
|
|
|
const parsedConfig = assistantEndpointSchema.parse(assistantsConfig);
|
|
|
|
|
if (assistantsConfig.supportedIds?.length && assistantsConfig.excludedIds?.length) {
|
|
|
|
|
logger.warn(
|
|
|
|
|
`Both \`supportedIds\` and \`excludedIds\` are defined for the ${EModelEndpoint.assistants} endpoint; \`excludedIds\` field will be ignored.`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...prevConfig,
|
|
|
|
|
retrievalModels: parsedConfig.retrievalModels,
|
|
|
|
|
disableBuilder: parsedConfig.disableBuilder,
|
|
|
|
|
pollIntervalMs: parsedConfig.pollIntervalMs,
|
|
|
|
|
supportedIds: parsedConfig.supportedIds,
|
|
|
|
|
capabilities: parsedConfig.capabilities,
|
|
|
|
|
excludedIds: parsedConfig.excludedIds,
|
|
|
|
|
timeoutMs: parsedConfig.timeoutMs,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-19 19:05:25 -04:00
|
|
|
module.exports = { azureAssistantsDefaults, assistantsConfigSetup };
|