mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix: Continue on fail / error output support for chains and agents (#9078)
This commit is contained in:
@@ -79,6 +79,7 @@ export async function conversationalAgentExecute(
|
||||
|
||||
const items = this.getInputData();
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
let input;
|
||||
|
||||
if (this.getNode().typeVersion <= 1.2) {
|
||||
@@ -109,6 +110,14 @@ export async function conversationalAgentExecute(
|
||||
}
|
||||
|
||||
returnData.push({ json: response });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.prepareOutputData(returnData);
|
||||
|
||||
@@ -85,6 +85,7 @@ export async function openAiFunctionsAgentExecute(
|
||||
|
||||
const items = this.getInputData();
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
let input;
|
||||
if (this.getNode().typeVersion <= 1.2) {
|
||||
input = this.getNodeParameter('text', itemIndex) as string;
|
||||
@@ -114,6 +115,14 @@ export async function openAiFunctionsAgentExecute(
|
||||
}
|
||||
|
||||
returnData.push({ json: response });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.prepareOutputData(returnData);
|
||||
|
||||
@@ -60,6 +60,7 @@ export async function planAndExecuteAgentExecute(
|
||||
|
||||
const items = this.getInputData();
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
let input;
|
||||
if (this.getNode().typeVersion <= 1.2) {
|
||||
input = this.getNodeParameter('text', itemIndex) as string;
|
||||
@@ -89,6 +90,14 @@ export async function planAndExecuteAgentExecute(
|
||||
}
|
||||
|
||||
returnData.push({ json: response });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.prepareOutputData(returnData);
|
||||
|
||||
@@ -80,6 +80,7 @@ export async function reActAgentAgentExecute(
|
||||
|
||||
const items = this.getInputData();
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
let input;
|
||||
|
||||
if (this.getNode().typeVersion <= 1.2) {
|
||||
@@ -110,6 +111,14 @@ export async function reActAgentAgentExecute(
|
||||
}
|
||||
|
||||
returnData.push({ json: response });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.prepareOutputData(returnData);
|
||||
|
||||
@@ -41,6 +41,7 @@ export async function sqlAgentAgentExecute(
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
const item = items[i];
|
||||
let input;
|
||||
if (this.getNode().typeVersion <= 1.2) {
|
||||
@@ -141,6 +142,14 @@ export async function sqlAgentAgentExecute(
|
||||
}
|
||||
|
||||
returnData.push({ json: response });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.prepareOutputData(returnData);
|
||||
|
||||
@@ -320,6 +320,7 @@ export class OpenAiAssistant implements INodeType {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
const input = this.getNodeParameter('text', itemIndex) as string;
|
||||
const assistantId = this.getNodeParameter('assistantId', itemIndex, '') as string;
|
||||
const nativeTools = this.getNodeParameter('nativeTools', itemIndex, []) as Array<
|
||||
@@ -381,6 +382,14 @@ export class OpenAiAssistant implements INodeType {
|
||||
});
|
||||
|
||||
returnData.push({ json: response });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.prepareOutputData(returnData);
|
||||
|
||||
@@ -519,6 +519,7 @@ export class ChainLlm implements INodeType {
|
||||
const outputParsers = await getOptionalOutputParsers(this);
|
||||
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
let prompt: string;
|
||||
if (this.getNode().typeVersion <= 1.3) {
|
||||
prompt = this.getNodeParameter('prompt', itemIndex) as string;
|
||||
@@ -537,7 +538,7 @@ export class ChainLlm implements INodeType {
|
||||
) as MessagesTemplate[];
|
||||
|
||||
if (prompt === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'The ‘prompt’ parameter is empty.');
|
||||
throw new NodeOperationError(this.getNode(), "The 'prompt' parameter is empty.");
|
||||
}
|
||||
|
||||
const responses = await getChain(this, itemIndex, prompt, llm, outputParsers, messages);
|
||||
@@ -568,6 +569,14 @@ export class ChainLlm implements INodeType {
|
||||
json: data,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
|
||||
@@ -160,6 +160,7 @@ export class ChainRetrievalQa implements INodeType {
|
||||
|
||||
// Run for each item
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
let query;
|
||||
|
||||
if (this.getNode().typeVersion <= 1.2) {
|
||||
@@ -179,6 +180,14 @@ export class ChainRetrievalQa implements INodeType {
|
||||
|
||||
const response = await chain.withConfig(getTracingConfig(this)).invoke({ query });
|
||||
returnData.push({ json: { response } });
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return await this.prepareOutputData(returnData);
|
||||
}
|
||||
|
||||
@@ -329,6 +329,7 @@ export class ChainSummarizationV2 implements INodeType {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
try {
|
||||
const summarizationMethodAndPrompts = this.getNodeParameter(
|
||||
'options.summarizationMethodAndPrompts.values',
|
||||
itemIndex,
|
||||
@@ -414,6 +415,14 @@ export class ChainSummarizationV2 implements INodeType {
|
||||
});
|
||||
returnData.push({ json: { response } });
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.prepareOutputData(returnData);
|
||||
|
||||
Reference in New Issue
Block a user