LangChain 代码节点方法(LangChain Code node methods)#
n8n 提供了这些方法,以便在 LangChain 代码节点 中更轻松地执行常见任务。
🌐 n8n provides these methods to make it easier to perform common tasks in the LangChain Code node.
仅限 LangChain 代码节点
这些变量用于在 LangChain 代码节点中的表达式中使用。你不能在其他节点中使用它们。
| Method | Description |
|---|---|
this.addInputData(inputName, data) |
Populate the data of a specified non-main input. Useful for mocking data.
|
this.addOutputData(outputName, data) |
Populate the data of a specified non-main output. Useful for mocking data.
|
this.getInputConnectionData(inputName, itemIndex, inputIndex?) |
Get data from a specified non-main 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. |