Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into N8N-7293-setup-helm…
Browse files Browse the repository at this point in the history
…et.js
  • Loading branch information
netroy committed Apr 10, 2024
2 parents 4bc112e + 9403657 commit f8a55c4
Show file tree
Hide file tree
Showing 50 changed files with 1,522 additions and 1,083 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,36 +79,45 @@ export async function conversationalAgentExecute(

const items = this.getInputData();
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
let input;

if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
try {
let input;

if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
}

returnData.push({ json: response });
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });

Check warning on line 115 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/ConversationalAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe assignment of an `any` value

Check warning on line 115 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/ConversationalAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe member access .message on an `any` value
continue;
}

throw error;
}

returnData.push({ json: response });
}

return await this.prepareOutputData(returnData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,44 @@ export async function openAiFunctionsAgentExecute(

const items = this.getInputData();
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
let input;
if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
try {
let input;
if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text‘ parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
}

returnData.push({ json: response });
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });

Check warning on line 120 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe assignment of an `any` value

Check warning on line 120 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe member access .message on an `any` value
continue;
}

throw error;
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text‘ parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
}

returnData.push({ json: response });
}

return await this.prepareOutputData(returnData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,44 @@ export async function planAndExecuteAgentExecute(

const items = this.getInputData();
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
let input;
if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
try {
let input;
if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text‘ parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
}

returnData.push({ json: response });
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });

Check warning on line 95 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe assignment of an `any` value

Check warning on line 95 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe member access .message on an `any` value
continue;
}

throw error;
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text‘ parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
}

returnData.push({ json: response });
}

return await this.prepareOutputData(returnData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,45 @@ export async function reActAgentAgentExecute(

const items = this.getInputData();
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
let input;

if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
try {
let input;

if (this.getNode().typeVersion <= 1.2) {
input = this.getNodeParameter('text', itemIndex) as string;
} else {
input = getPromptInputByType({
ctx: this,
i: itemIndex,
inputKey: 'text',
promptTypeKey: 'promptType',
});
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text‘ parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
}

returnData.push({ json: response });
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });

Check warning on line 116 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/ReActAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe assignment of an `any` value

Check warning on line 116 in packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/ReActAgent/execute.ts

View workflow job for this annotation

GitHub Actions / Lint changes

Unsafe member access .message on an `any` value
continue;
}

throw error;
}

if (input === undefined) {
throw new NodeOperationError(this.getNode(), 'The ‘text‘ parameter is empty.');
}

if (prompt) {
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
}

returnData.push({ json: response });
}

return await this.prepareOutputData(returnData);
Expand Down
Loading

0 comments on commit f8a55c4

Please sign in to comment.