构建工作流

LangChain Code node

n8n provides these methods to make it easier to perform common tasks in the LangChain Code node.

Method Description
this.addInputData(inputName, data) Populate the data of a specified non-main input. Useful for mocking data.<code>inputName</code> is the input connection type, and must be one of: <code>ai\_agent</code>, <code>ai\_chain</code>, <code>ai\_document</code>, <code>ai\_embedding</code>, <code>ai\_languageModel</code>, <code>ai\_memory</code>, <code>ai\_outputParser</code>, <code>ai\_retriever</code>, <code>ai\_textSplitter</code>, <code>ai\_tool</code>, <code>ai\_vectorRetriever</code>, <code>ai\_vectorStore</code><code>data</code> contains the data you want to add. Refer to Data structure for information on the data structure expected by n8n.
this.addOutputData(outputName, data) Populate the data of a specified non-main output. Useful for mocking data.<code>outputName</code> is the input connection type, and must be one of: <code>ai\_agent</code>, <code>ai\_chain</code>, <code>ai\_document</code>, <code>ai\_embedding</code>, <code>ai\_languageModel</code>, <code>ai\_memory</code>, <code>ai\_outputParser</code>, <code>ai\_retriever</code>, <code>ai\_textSplitter</code>, <code>ai\_tool</code>, <code>ai\_vectorRetriever</code>, <code>ai\_vectorStore</code><code>data</code> contains the data you want to add. Refer to Data structure for information on the data structure expected by n8n.
this.getInputConnectionData(inputName, itemIndex, inputIndex?) Get data from a specified non-main input.<code>inputName</code> is the input connection type, and must be one of: <code>ai\_agent</code>, <code>ai\_chain</code>, <code>ai\_document</code>, <code>ai\_embedding</code>, <code>ai\_languageModel</code>, <code>ai\_memory</code>, <code>ai\_outputParser</code>, <code>ai\_retriever</code>, <code>ai\_textSplitter</code>, <code>ai\_tool</code>, <code>ai\_vectorRetriever</code>, <code>ai\_vectorStore</code><code>itemIndex</code> should always be <code>0</code> (this parameter will be used in upcoming functionality)Use <code>inputIndex</code> if there is more than one node connected to the specified input.
this.getInputData(inputIndex?, inputName?) Get data from the main input.
this.getNode() Get the current node.
this.getNodeOutputs() Get the outputs of the current node.
this.getExecutionCancelSignal() Use this to stop the execution of a function when the workflow stops. In most cases n8n handles this, but you may need to use it if building your own chains or agents. It replaces the Cancelling a running LLMChain code that you'd use if building a LangChain application normally.

官方原文和授权

本页来自 N8N 英文官方网站固定快照,并转换成 xueai 静态页面。内容以 N8N 持续更新的官方页面为准。

来源、授权与修改

本站保留许可证、固定提交号、社区作者和修改说明,不代表 n8n 对本站背书。

查看许可证查看来源和修改说明