@n8n/n8n-nodes-langchain
Version:

141 lines • 4.96 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var AgentV3_node_exports = {};
__export(AgentV3_node_exports, {
AgentV3: () => AgentV3
});
module.exports = __toCommonJS(AgentV3_node_exports);
var import_n8n_workflow = require("n8n-workflow");
var import_descriptions = require("../../../../utils/descriptions");
var import_description = require("../agents/ToolsAgent/V3/description");
var import_execute = require("../agents/ToolsAgent/V3/execute");
var import_utils = require("../utils");
class AgentV3 {
constructor(baseDescription) {
this.description = {
...baseDescription,
version: [3, 3.1],
defaults: {
name: "AI Agent",
color: "#404040"
},
inputs: `={{
((hasOutputParser, needsFallback) => {
${import_utils.getInputs.toString()};
return getInputs(true, hasOutputParser, needsFallback);
})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true, $parameter.needsFallback !== undefined && $parameter.needsFallback === true)
}}`,
outputs: [import_n8n_workflow.NodeConnectionTypes.Main],
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: ""
},
{
...import_descriptions.promptTypeOptionsDeprecated,
displayOptions: { show: { "@version": [{ _cnd: { lt: 3.1 } }] } }
},
{
...import_descriptions.promptTypeOptions,
displayOptions: { show: { "@version": [{ _cnd: { gte: 3.1 } }] } }
},
{
...import_descriptions.textFromGuardrailsNode,
displayOptions: {
show: {
promptType: ["guardrails"]
}
}
},
{
...import_descriptions.textFromPreviousNode,
displayOptions: {
show: {
promptType: ["auto"]
}
}
},
{
...import_descriptions.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='${import_n8n_workflow.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
},
{
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]
}
}
},
import_description.toolsAgentProperties
],
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(response) {
return await import_execute.toolsAgentExecute.call(this, response);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AgentV3
});
//# sourceMappingURL=AgentV3.node.js.map