feat: Optimise langchain calls in batching mode (#15243)

This commit is contained in:
Benjamin Schroth
2025-05-13 13:58:38 +02:00
committed by GitHub
parent 8591c2e0d1
commit ff156930c5
35 changed files with 2946 additions and 1171 deletions

View File

@@ -11,7 +11,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
import type { IExecutionResponse, INodeUi, IWorkflowDb, IWorkflowSettings } from '@/Interface';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { SEND_AND_WAIT_OPERATION } from 'n8n-workflow';
import { deepCopy, SEND_AND_WAIT_OPERATION } from 'n8n-workflow';
import type {
IPinData,
ExecutionSummary,
@@ -658,6 +658,65 @@ describe('useWorkflowsStore', () => {
TestNode1: [{ json: { test: false } }],
});
});
it('should replace existing placeholder task data in new log view', () => {
settingsStore.settings = {
logsView: {
enabled: true,
},
} as FrontendSettings;
const successEventWithExecutionIndex = deepCopy(successEvent);
successEventWithExecutionIndex.data.executionIndex = 1;
const runWithExistingRunData = executionResponse;
runWithExistingRunData.data = {
resultData: {
runData: {
[successEventWithExecutionIndex.nodeName]: [
{
hints: [],
startTime: 1727867966633,
executionIndex: successEventWithExecutionIndex.data.executionIndex,
executionTime: 1,
source: [],
executionStatus: 'running',
data: {
main: [
[
{
json: {},
pairedItem: {
item: 0,
},
},
],
],
},
},
],
},
},
};
workflowsStore.setWorkflowExecutionData(runWithExistingRunData);
workflowsStore.nodesByName[successEvent.nodeName] = mock<INodeUi>({
type: 'n8n-nodes-base.manualTrigger',
});
// ACT
workflowsStore.updateNodeExecutionData(successEventWithExecutionIndex);
expect(workflowsStore.workflowExecutionData).toEqual({
...executionResponse,
data: {
resultData: {
runData: {
[successEvent.nodeName]: [successEventWithExecutionIndex.data],
},
},
},
});
});
});
describe('setNodeValue()', () => {

View File

@@ -1541,10 +1541,16 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
openFormPopupWindow(testUrl);
}
} else {
const status = tasksData[tasksData.length - 1]?.executionStatus ?? 'unknown';
// If we process items in paralell on subnodes we get several placeholder taskData items.
// We need to find and replace the item with the matching executionIndex and only append if we don't find anything matching.
const existingRunIndex = tasksData.findIndex(
(item) => item.executionIndex === data.executionIndex,
);
const index = existingRunIndex > -1 ? existingRunIndex : tasksData.length - 1;
const status = tasksData[index]?.executionStatus ?? 'unknown';
if ('waiting' === status || (settingsStore.isNewLogsEnabled && 'running' === status)) {
tasksData.splice(tasksData.length - 1, 1, data);
tasksData.splice(index, 1, data);
} else {
tasksData.push(data);
}