From 2dcf04db76b1e59a90046bd4a163180d9a7f8c1a Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour Date: Fri, 8 Nov 2024 18:13:07 +0100 Subject: [PATCH] feat: support workflow retrieval debugging --- .../RetrieverWorkflow/RetrieverWorkflow.node.ts | 1 + packages/@n8n/nodes-langchain/utils/logWrapper.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/@n8n/nodes-langchain/nodes/retrievers/RetrieverWorkflow/RetrieverWorkflow.node.ts b/packages/@n8n/nodes-langchain/nodes/retrievers/RetrieverWorkflow/RetrieverWorkflow.node.ts index fab3c2dabe..b2e762db88 100644 --- a/packages/@n8n/nodes-langchain/nodes/retrievers/RetrieverWorkflow/RetrieverWorkflow.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/retrievers/RetrieverWorkflow/RetrieverWorkflow.node.ts @@ -418,6 +418,7 @@ export class RetrieverWorkflow implements INodeType { metadata: { ...baseMetadata, itemIndex: index, + executionId: receivedData.executionId, }, }), ); diff --git a/packages/@n8n/nodes-langchain/utils/logWrapper.ts b/packages/@n8n/nodes-langchain/utils/logWrapper.ts index 10e55ba6ef..3a3a11dad2 100644 --- a/packages/@n8n/nodes-langchain/utils/logWrapper.ts +++ b/packages/@n8n/nodes-langchain/utils/logWrapper.ts @@ -220,8 +220,14 @@ export function logWrapper( arguments: [query, config], })) as Array>>; + const executionId: string | undefined = response[0]?.metadata?.executionId as string; + const workflowId: string | undefined = response[0]?.metadata?.workflowId as string; + logAiEvent(executeFunctions, 'ai-documents-retrieved', { query }); - executeFunctions.addOutputData(connectionType, index, [[{ json: { response } }]]); + executeFunctions.addOutputData(connectionType, index, [[{ json: { response } }]], { + executionId, + workflowId, + }); return response; }; }