mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
* fix: Update logger import to use data-schemas module * feat: agent model validation * fix: Remove invalid error messages from translation file
29 lines
882 B
JavaScript
29 lines
882 B
JavaScript
const { logger } = require('@librechat/data-schemas');
|
|
const { isAgentsEndpoint, removeNullishValues, Constants } = require('librechat-data-provider');
|
|
const { loadAgent } = require('~/models/Agent');
|
|
|
|
const buildOptions = (req, endpoint, parsedBody, endpointType) => {
|
|
const { spec, iconURL, agent_id, instructions, ...model_parameters } = parsedBody;
|
|
const agentPromise = loadAgent({
|
|
req,
|
|
agent_id: isAgentsEndpoint(endpoint) ? agent_id : Constants.EPHEMERAL_AGENT_ID,
|
|
endpoint,
|
|
model_parameters,
|
|
}).catch((error) => {
|
|
logger.error(`[/agents/:${agent_id}] Error retrieving agent during build options step`, error);
|
|
return undefined;
|
|
});
|
|
|
|
return removeNullishValues({
|
|
spec,
|
|
iconURL,
|
|
endpoint,
|
|
agent_id,
|
|
endpointType,
|
|
instructions,
|
|
model_parameters,
|
|
agent: agentPromise,
|
|
});
|
|
};
|
|
|
|
module.exports = { buildOptions };
|