feat(core): Add support for building LLM applications (#7235)

This extracts all core and editor changes from #7246 and #7137, so that
we can get these changes merged first.

ADO-1120

[DB Tests](https://github.com/n8n-io/n8n/actions/runs/6379749011)
[E2E Tests](https://github.com/n8n-io/n8n/actions/runs/6379751480)
[Workflow Tests](https://github.com/n8n-io/n8n/actions/runs/6379752828)

---------

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Alex Grozav <alex@grozav.com>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-10-02 17:33:43 +02:00
committed by GitHub
parent 04dfcd73be
commit 00a4b8b0c6
93 changed files with 6209 additions and 728 deletions

View File

@@ -134,7 +134,7 @@ import type {
IRunExecutionData,
Workflow,
} from 'n8n-workflow';
import { jsonParse } from 'n8n-workflow';
import { jsonParse, NodeHelpers, NodeConnectionType } from 'n8n-workflow';
import type { IExecutionResponse, INodeUi, IUpdateInformation, TargetItem } from '@/Interface';
import { externalHooks } from '@/mixins/externalHooks';
@@ -299,7 +299,7 @@ export default defineComponent({
return null;
}
const executionData: IRunExecutionData | undefined = this.workflowExecution.data;
if (executionData && executionData.resultData) {
if (executionData?.resultData) {
return executionData.resultData.runData;
}
return null;
@@ -329,18 +329,27 @@ export default defineComponent({
return Math.min(this.runOutputIndex, this.maxOutputRun);
},
maxInputRun(): number {
if (this.inputNode === null) {
if (this.inputNode === null && this.activeNode === null) {
return 0;
}
const workflowNode = this.workflow.getNode(this.activeNode.name);
const outputs = NodeHelpers.getNodeOutputs(this.workflow, workflowNode, this.activeNodeType);
let node = this.inputNode;
const runData: IRunData | null = this.workflowRunData;
if (runData === null || !runData.hasOwnProperty(this.inputNode.name)) {
if (outputs.filter((output) => output !== NodeConnectionType.Main).length) {
node = this.activeNode;
}
if (!node || !runData || !runData.hasOwnProperty(node.name)) {
return 0;
}
if (runData[this.inputNode.name].length) {
return runData[this.inputNode.name].length - 1;
if (runData[node.name].length) {
return runData[node.name].length - 1;
}
return 0;
@@ -539,7 +548,7 @@ export default defineComponent({
node_type: this.activeNode.type,
workflow_id: this.workflowsStore.workflowId,
session_id: this.sessionId,
pane: 'main',
pane: NodeConnectionType.Main,
type: 'i-wish-this-node-would',
});
}
@@ -607,6 +616,19 @@ export default defineComponent({
return;
}
if (
typeof this.activeNodeType.outputs === 'string' ||
typeof this.activeNodeType.inputs === 'string'
) {
// TODO: We should keep track of if it actually changed and only do if required
// Whenever a node with custom inputs and outputs gets closed redraw it in case
// they changed
const nodeName = this.activeNode.name;
setTimeout(() => {
this.$emit('redrawNode', nodeName);
}, 1);
}
if (this.outputPanelEditMode.enabled) {
const shouldPinDataBeforeClosing = await this.confirm(
'',