mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
31 lines
694 B
JavaScript
31 lines
694 B
JavaScript
|
|
const { getAgent } = require('~/models/Agent');
|
||
|
|
const { logger } = require('~/config');
|
||
|
|
|
||
|
|
const buildOptions = (req, endpoint, parsedBody) => {
|
||
|
|
const { agent_id, instructions, spec, ...rest } = parsedBody;
|
||
|
|
|
||
|
|
const agentPromise = getAgent({
|
||
|
|
id: agent_id,
|
||
|
|
// TODO: better author handling
|
||
|
|
author: req.user.id,
|
||
|
|
}).catch((error) => {
|
||
|
|
logger.error(`[/agents/:${agent_id}] Error retrieving agent during build options step`, error);
|
||
|
|
return undefined;
|
||
|
|
});
|
||
|
|
|
||
|
|
const endpointOption = {
|
||
|
|
agent: agentPromise,
|
||
|
|
endpoint,
|
||
|
|
agent_id,
|
||
|
|
instructions,
|
||
|
|
spec,
|
||
|
|
modelOptions: {
|
||
|
|
...rest,
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
return endpointOption;
|
||
|
|
};
|
||
|
|
|
||
|
|
module.exports = { buildOptions };
|