@n8n/n8n-nodes-langchain
Version:

128 lines • 5.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgentV2 = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const descriptions_1 = require("../../../../utils/descriptions");
const description_1 = require("../agents/ToolsAgent/V2/description");
const execute_1 = require("../agents/ToolsAgent/V2/execute");
const utils_1 = require("../utils");
class AgentV2 {
constructor(baseDescription) {
this.description = {
...baseDescription,
version: [2, 2.1, 2.2],
defaults: {
name: 'AI Agent',
color: '#404040',
},
inputs: `={{
((hasOutputParser, needsFallback) => {
${utils_1.getInputs.toString()};
return getInputs(true, hasOutputParser, needsFallback);
})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true, $parameter.needsFallback !== undefined && $parameter.needsFallback === true)
}}`,
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
builderHint: {
...baseDescription.builderHint,
inputs: {
ai_languageModel: { required: true },
ai_memory: { required: false },
ai_tool: { required: false },
ai_outputParser: {
required: false,
displayOptions: { show: { hasOutputParser: [true] } },
},
},
},
properties: [
{
displayName: 'Tip: Get a feel for agents with our quick <a href="https://docs.n8n.io/advanced-ai/intro-tutorial/" target="_blank">tutorial</a> or see an <a href="/workflows/templates/1954" target="_blank">example</a> of how this node works',
name: 'aiAgentStarterCallout',
type: 'callout',
default: '',
},
descriptions_1.promptTypeOptionsDeprecated,
{
...descriptions_1.textFromGuardrailsNode,
displayOptions: {
show: {
promptType: ['guardrails'],
},
},
},
{
...descriptions_1.textFromPreviousNode,
displayOptions: {
show: {
promptType: ['auto'],
},
},
},
{
...descriptions_1.textInput,
displayOptions: {
show: {
promptType: ['define'],
},
},
},
{
displayName: 'Require Specific Output Format',
name: 'hasOutputParser',
type: 'boolean',
default: false,
noDataExpression: true,
},
{
displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${n8n_workflow_1.NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,
name: 'notice',
type: 'notice',
default: '',
displayOptions: {
show: {
hasOutputParser: [true],
},
},
},
{
displayName: 'Enable Fallback Model',
name: 'needsFallback',
type: 'boolean',
default: false,
noDataExpression: true,
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 2.1 } }],
},
},
},
{
displayName: 'Connect an additional language model on the canvas to use it as a fallback if the main model fails',
name: 'fallbackNotice',
type: 'notice',
default: '',
displayOptions: {
show: {
needsFallback: [true],
},
},
},
...(0, description_1.getToolsAgentProperties)({ withStreaming: true }),
],
hints: [
{
message: 'You are using streaming responses. Make sure to set the response mode to "Streaming Response" on the connected trigger node.',
type: 'warning',
location: 'outputPane',
whenToDisplay: 'afterExecution',
displayCondition: '={{ $parameter["enableStreaming"] === true }}',
},
],
};
}
async execute() {
return await execute_1.toolsAgentExecute.call(this);
}
}
exports.AgentV2 = AgentV2;
//# sourceMappingURL=AgentV2.node.js.map