refactor: Migrate NodeConnectionType to const object type (no-changelog) (#14078)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Alex Grozav
2025-03-21 14:01:26 +02:00
committed by GitHub
parent 7e8179b848
commit 8215e0b59f
703 changed files with 3104 additions and 3018 deletions

View File

@@ -1,4 +1,4 @@
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
INodeInputConfiguration, INodeInputConfiguration,
INodeInputFilter, INodeInputFilter,
@@ -7,6 +7,7 @@ import type {
INodeType, INodeType,
INodeTypeDescription, INodeTypeDescription,
INodeProperties, INodeProperties,
NodeConnectionType,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions'; import { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';
@@ -85,7 +86,7 @@ function getInputs(
if (agent === 'conversationalAgent') { if (agent === 'conversationalAgent') {
specialInputs = [ specialInputs = [
{ {
type: NodeConnectionType.AiLanguageModel, type: 'ai_languageModel',
filter: { filter: {
nodes: [ nodes: [
'@n8n/n8n-nodes-langchain.lmChatAnthropic', '@n8n/n8n-nodes-langchain.lmChatAnthropic',
@@ -103,19 +104,19 @@ function getInputs(
}, },
}, },
{ {
type: NodeConnectionType.AiMemory, type: 'ai_memory',
}, },
{ {
type: NodeConnectionType.AiTool, type: 'ai_tool',
}, },
{ {
type: NodeConnectionType.AiOutputParser, type: 'ai_outputParser',
}, },
]; ];
} else if (agent === 'toolsAgent') { } else if (agent === 'toolsAgent') {
specialInputs = [ specialInputs = [
{ {
type: NodeConnectionType.AiLanguageModel, type: 'ai_languageModel',
filter: { filter: {
nodes: [ nodes: [
'@n8n/n8n-nodes-langchain.lmChatAnthropic', '@n8n/n8n-nodes-langchain.lmChatAnthropic',
@@ -133,20 +134,20 @@ function getInputs(
}, },
}, },
{ {
type: NodeConnectionType.AiMemory, type: 'ai_memory',
}, },
{ {
type: NodeConnectionType.AiTool, type: 'ai_tool',
required: true, required: true,
}, },
{ {
type: NodeConnectionType.AiOutputParser, type: 'ai_outputParser',
}, },
]; ];
} else if (agent === 'openAiFunctionsAgent') { } else if (agent === 'openAiFunctionsAgent') {
specialInputs = [ specialInputs = [
{ {
type: NodeConnectionType.AiLanguageModel, type: 'ai_languageModel',
filter: { filter: {
nodes: [ nodes: [
'@n8n/n8n-nodes-langchain.lmChatOpenAi', '@n8n/n8n-nodes-langchain.lmChatOpenAi',
@@ -155,57 +156,55 @@ function getInputs(
}, },
}, },
{ {
type: NodeConnectionType.AiMemory, type: 'ai_memory',
}, },
{ {
type: NodeConnectionType.AiTool, type: 'ai_tool',
required: true, required: true,
}, },
{ {
type: NodeConnectionType.AiOutputParser, type: 'ai_outputParser',
}, },
]; ];
} else if (agent === 'reActAgent') { } else if (agent === 'reActAgent') {
specialInputs = [ specialInputs = [
{ {
type: NodeConnectionType.AiLanguageModel, type: 'ai_languageModel',
}, },
{ {
type: NodeConnectionType.AiTool, type: 'ai_tool',
}, },
{ {
type: NodeConnectionType.AiOutputParser, type: 'ai_outputParser',
}, },
]; ];
} else if (agent === 'sqlAgent') { } else if (agent === 'sqlAgent') {
specialInputs = [ specialInputs = [
{ {
type: NodeConnectionType.AiLanguageModel, type: 'ai_languageModel',
}, },
{ {
type: NodeConnectionType.AiMemory, type: 'ai_memory',
}, },
]; ];
} else if (agent === 'planAndExecuteAgent') { } else if (agent === 'planAndExecuteAgent') {
specialInputs = [ specialInputs = [
{ {
type: NodeConnectionType.AiLanguageModel, type: 'ai_languageModel',
}, },
{ {
type: NodeConnectionType.AiTool, type: 'ai_tool',
}, },
{ {
type: NodeConnectionType.AiOutputParser, type: 'ai_outputParser',
}, },
]; ];
} }
if (hasOutputParser === false) { if (hasOutputParser === false) {
specialInputs = specialInputs.filter( specialInputs = specialInputs.filter((input) => input.type !== 'ai_outputParser');
(input) => input.type !== NodeConnectionType.AiOutputParser,
);
} }
return [NodeConnectionType.Main, ...getInputData(specialInputs)]; return ['main', ...getInputData(specialInputs)];
} }
const agentTypeProperty: INodeProperties = { const agentTypeProperty: INodeProperties = {
@@ -290,7 +289,7 @@ export class Agent implements INodeType {
return getInputs(agent, hasOutputParser) return getInputs(agent, hasOutputParser)
})($parameter.agent, $parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true) })($parameter.agent, $parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true)
}}`, }}`,
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [ credentials: [
{ {
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed // eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
@@ -430,7 +429,7 @@ export class Agent implements INodeType {
}, },
}, },
{ {
displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionType.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`, displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,
name: 'notice', name: 'notice',
type: 'notice', type: 'notice',
default: '', default: '',

View File

@@ -2,7 +2,7 @@ import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
import { PromptTemplate } from '@langchain/core/prompts'; import { PromptTemplate } from '@langchain/core/prompts';
import { initializeAgentExecutorWithOptions } from 'langchain/agents'; import { initializeAgentExecutorWithOptions } from 'langchain/agents';
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import { isChatInstance, getPromptInputByType, getConnectedTools } from '@utils/helpers'; import { isChatInstance, getPromptInputByType, getConnectedTools } from '@utils/helpers';
import { getOptionalOutputParser } from '@utils/output_parsers/N8nOutputParser'; import { getOptionalOutputParser } from '@utils/output_parsers/N8nOutputParser';
@@ -16,13 +16,13 @@ export async function conversationalAgentExecute(
nodeVersion: number, nodeVersion: number,
): Promise<INodeExecutionData[][]> { ): Promise<INodeExecutionData[][]> {
this.logger.debug('Executing Conversational Agent'); this.logger.debug('Executing Conversational Agent');
const model = await this.getInputConnectionData(NodeConnectionType.AiLanguageModel, 0); const model = await this.getInputConnectionData(NodeConnectionTypes.AiLanguageModel, 0);
if (!isChatInstance(model)) { if (!isChatInstance(model)) {
throw new NodeOperationError(this.getNode(), 'Conversational Agent requires Chat Model'); throw new NodeOperationError(this.getNode(), 'Conversational Agent requires Chat Model');
} }
const memory = (await this.getInputConnectionData(NodeConnectionType.AiMemory, 0)) as const memory = (await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as
| BaseChatMemory | BaseChatMemory
| undefined; | undefined;

View File

@@ -6,7 +6,7 @@ import { BufferMemory, type BaseChatMemory } from 'langchain/memory';
import { import {
type IExecuteFunctions, type IExecuteFunctions,
type INodeExecutionData, type INodeExecutionData,
NodeConnectionType, NodeConnectionTypes,
NodeOperationError, NodeOperationError,
} from 'n8n-workflow'; } from 'n8n-workflow';
@@ -22,7 +22,7 @@ export async function openAiFunctionsAgentExecute(
): Promise<INodeExecutionData[][]> { ): Promise<INodeExecutionData[][]> {
this.logger.debug('Executing OpenAi Functions Agent'); this.logger.debug('Executing OpenAi Functions Agent');
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as ChatOpenAI; )) as ChatOpenAI;
@@ -32,7 +32,7 @@ export async function openAiFunctionsAgentExecute(
'OpenAI Functions Agent requires OpenAI Chat Model', 'OpenAI Functions Agent requires OpenAI Chat Model',
); );
} }
const memory = (await this.getInputConnectionData(NodeConnectionType.AiMemory, 0)) as const memory = (await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as
| BaseChatMemory | BaseChatMemory
| undefined; | undefined;
const tools = await getConnectedTools(this, nodeVersion >= 1.5, false); const tools = await getConnectedTools(this, nodeVersion >= 1.5, false);

View File

@@ -4,7 +4,7 @@ import { PlanAndExecuteAgentExecutor } from 'langchain/experimental/plan_and_exe
import { import {
type IExecuteFunctions, type IExecuteFunctions,
type INodeExecutionData, type INodeExecutionData,
NodeConnectionType, NodeConnectionTypes,
NodeOperationError, NodeOperationError,
} from 'n8n-workflow'; } from 'n8n-workflow';
@@ -21,7 +21,7 @@ export async function planAndExecuteAgentExecute(
): Promise<INodeExecutionData[][]> { ): Promise<INodeExecutionData[][]> {
this.logger.debug('Executing PlanAndExecute Agent'); this.logger.debug('Executing PlanAndExecute Agent');
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseChatModel; )) as BaseChatModel;

View File

@@ -5,7 +5,7 @@ import { AgentExecutor, ChatAgent, ZeroShotAgent } from 'langchain/agents';
import { import {
type IExecuteFunctions, type IExecuteFunctions,
type INodeExecutionData, type INodeExecutionData,
NodeConnectionType, NodeConnectionTypes,
NodeOperationError, NodeOperationError,
} from 'n8n-workflow'; } from 'n8n-workflow';
@@ -22,7 +22,7 @@ export async function reActAgentAgentExecute(
): Promise<INodeExecutionData[][]> { ): Promise<INodeExecutionData[][]> {
this.logger.debug('Executing ReAct Agent'); this.logger.debug('Executing ReAct Agent');
const model = (await this.getInputConnectionData(NodeConnectionType.AiLanguageModel, 0)) as const model = (await this.getInputConnectionData(NodeConnectionTypes.AiLanguageModel, 0)) as
| BaseLanguageModel | BaseLanguageModel
| BaseChatModel; | BaseChatModel;

View File

@@ -7,7 +7,7 @@ import { SqlDatabase } from 'langchain/sql_db';
import { import {
type IExecuteFunctions, type IExecuteFunctions,
type INodeExecutionData, type INodeExecutionData,
NodeConnectionType, NodeConnectionTypes,
NodeOperationError, NodeOperationError,
type IDataObject, type IDataObject,
} from 'n8n-workflow'; } from 'n8n-workflow';
@@ -32,7 +32,7 @@ export async function sqlAgentAgentExecute(
this.logger.debug('Executing SQL Agent'); this.logger.debug('Executing SQL Agent');
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;
const items = this.getInputData(); const items = this.getInputData();
@@ -113,7 +113,7 @@ export async function sqlAgentAgentExecute(
const toolkit = new SqlToolkit(dbInstance, model); const toolkit = new SqlToolkit(dbInstance, model);
const agentExecutor = createSqlAgent(model, toolkit, agentOptions); const agentExecutor = createSqlAgent(model, toolkit, agentOptions);
const memory = (await this.getInputConnectionData(NodeConnectionType.AiMemory, 0)) as const memory = (await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as
| BaseChatMemory | BaseChatMemory
| undefined; | undefined;

View File

@@ -11,7 +11,7 @@ import type { AgentAction, AgentFinish } from 'langchain/agents';
import { AgentExecutor, createToolCallingAgent } from 'langchain/agents'; import { AgentExecutor, createToolCallingAgent } from 'langchain/agents';
import type { ToolsAgentAction } from 'langchain/dist/agents/tool_calling/output_parser'; import type { ToolsAgentAction } from 'langchain/dist/agents/tool_calling/output_parser';
import { omit } from 'lodash'; import { omit } from 'lodash';
import { BINARY_ENCODING, jsonParse, NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { BINARY_ENCODING, jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import type { ZodObject } from 'zod'; import type { ZodObject } from 'zod';
import { z } from 'zod'; import { z } from 'zod';
@@ -275,7 +275,7 @@ export const getAgentStepsParser =
* @returns The validated chat model * @returns The validated chat model
*/ */
export async function getChatModel(ctx: IExecuteFunctions): Promise<BaseChatModel> { export async function getChatModel(ctx: IExecuteFunctions): Promise<BaseChatModel> {
const model = await ctx.getInputConnectionData(NodeConnectionType.AiLanguageModel, 0); const model = await ctx.getInputConnectionData(NodeConnectionTypes.AiLanguageModel, 0);
if (!isChatInstance(model) || !model.bindTools) { if (!isChatInstance(model) || !model.bindTools) {
throw new NodeOperationError( throw new NodeOperationError(
ctx.getNode(), ctx.getNode(),
@@ -294,7 +294,7 @@ export async function getChatModel(ctx: IExecuteFunctions): Promise<BaseChatMode
export async function getOptionalMemory( export async function getOptionalMemory(
ctx: IExecuteFunctions, ctx: IExecuteFunctions,
): Promise<BaseChatMemory | undefined> { ): Promise<BaseChatMemory | undefined> {
return (await ctx.getInputConnectionData(NodeConnectionType.AiMemory, 0)) as return (await ctx.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as
| BaseChatMemory | BaseChatMemory
| undefined; | undefined;
} }

View File

@@ -1,7 +1,7 @@
import { AgentExecutor } from 'langchain/agents'; import { AgentExecutor } from 'langchain/agents';
import type { OpenAIToolType } from 'langchain/dist/experimental/openai_assistant/schema'; import type { OpenAIToolType } from 'langchain/dist/experimental/openai_assistant/schema';
import { OpenAIAssistantRunnable } from 'langchain/experimental/openai_assistant'; import { OpenAIAssistantRunnable } from 'langchain/experimental/openai_assistant';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
IExecuteFunctions, IExecuteFunctions,
INodeExecutionData, INodeExecutionData,
@@ -44,10 +44,10 @@ export class OpenAiAssistant implements INodeType {
}, },
}, },
inputs: [ inputs: [
{ type: NodeConnectionType.Main }, { type: NodeConnectionTypes.Main },
{ type: NodeConnectionType.AiTool, displayName: 'Tools' }, { type: NodeConnectionTypes.AiTool, displayName: 'Tools' },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [ credentials: [
{ {
name: 'openAiApi', name: 'openAiApi',

View File

@@ -5,7 +5,7 @@ import type {
INodeType, INodeType,
INodeTypeDescription, INodeTypeDescription,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeApiError, NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeApiError, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import { getPromptInputByType } from '@utils/helpers'; import { getPromptInputByType } from '@utils/helpers';
import { getOptionalOutputParser } from '@utils/output_parsers/N8nOutputParser'; import { getOptionalOutputParser } from '@utils/output_parsers/N8nOutputParser';
@@ -55,7 +55,7 @@ export class ChainLlm implements INodeType {
}, },
}, },
inputs: `={{ ((parameter) => { ${getInputs.toString()}; return getInputs(parameter) })($parameter) }}`, inputs: `={{ ((parameter) => { ${getInputs.toString()}; return getInputs(parameter) })($parameter) }}`,
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [], credentials: [],
properties: nodeProperties, properties: nodeProperties,
}; };
@@ -73,7 +73,7 @@ export class ChainLlm implements INodeType {
try { try {
// Get the language model // Get the language model
const llm = (await this.getInputConnectionData( const llm = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;

View File

@@ -3,8 +3,8 @@ import {
HumanMessagePromptTemplate, HumanMessagePromptTemplate,
SystemMessagePromptTemplate, SystemMessagePromptTemplate,
} from '@langchain/core/prompts'; } from '@langchain/core/prompts';
import type { IDataObject, INodeProperties } from 'n8n-workflow'; import type { IDataObject, INodeInputConfiguration, INodeProperties } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { promptTypeOptions, textFromPreviousNode } from '@utils/descriptions'; import { promptTypeOptions, textFromPreviousNode } from '@utils/descriptions';
import { getTemplateNoticeField } from '@utils/sharedFields'; import { getTemplateNoticeField } from '@utils/sharedFields';
@@ -13,7 +13,7 @@ import { getTemplateNoticeField } from '@utils/sharedFields';
* Dynamic input configuration generation based on node parameters * Dynamic input configuration generation based on node parameters
*/ */
export function getInputs(parameters: IDataObject) { export function getInputs(parameters: IDataObject) {
const inputs = [ const inputs: INodeInputConfiguration[] = [
{ displayName: '', type: 'main' }, { displayName: '', type: 'main' },
{ {
displayName: 'Model', displayName: 'Model',
@@ -260,7 +260,7 @@ export const nodeProperties: INodeProperties[] = [
], ],
}, },
{ {
displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionType.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`, displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,
name: 'notice', name: 'notice',
type: 'notice', type: 'notice',
default: '', default: '',

View File

@@ -3,7 +3,7 @@ import { HumanMessage } from '@langchain/core/messages';
import { ChatGoogleGenerativeAI } from '@langchain/google-genai'; import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
import { ChatOllama } from '@langchain/ollama'; import { ChatOllama } from '@langchain/ollama';
import type { IExecuteFunctions, IBinaryData } from 'n8n-workflow'; import type { IExecuteFunctions, IBinaryData } from 'n8n-workflow';
import { NodeOperationError, NodeConnectionType, OperationalError } from 'n8n-workflow'; import { NodeOperationError, NodeConnectionTypes, OperationalError } from 'n8n-workflow';
import type { MessageTemplate } from './types'; import type { MessageTemplate } from './types';
@@ -69,7 +69,7 @@ export async function createImageMessage({
const bufferData = await context.helpers.getBinaryDataBuffer(itemIndex, binaryDataKey); const bufferData = await context.helpers.getBinaryDataBuffer(itemIndex, binaryDataKey);
const model = (await context.getInputConnectionData( const model = (await context.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;

View File

@@ -3,7 +3,7 @@
import { FakeChatModel } from '@langchain/core/utils/testing'; import { FakeChatModel } from '@langchain/core/utils/testing';
import { mock } from 'jest-mock-extended'; import { mock } from 'jest-mock-extended';
import type { IExecuteFunctions, INode } from 'n8n-workflow'; import type { IExecuteFunctions, INode } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import * as helperModule from '@utils/helpers'; import * as helperModule from '@utils/helpers';
import * as outputParserModule from '@utils/output_parsers/N8nOutputParser'; import * as outputParserModule from '@utils/output_parsers/N8nOutputParser';
@@ -64,7 +64,7 @@ describe('ChainLlm Node', () => {
expect(node.description.version).toContain(1.5); expect(node.description.version).toContain(1.5);
expect(node.description.properties).toBeDefined(); expect(node.description.properties).toBeDefined();
expect(node.description.inputs).toBeDefined(); expect(node.description.inputs).toBeDefined();
expect(node.description.outputs).toEqual([NodeConnectionType.Main]); expect(node.description.outputs).toEqual([NodeConnectionTypes.Main]);
}); });
}); });

View File

@@ -1,4 +1,4 @@
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { getInputs, nodeProperties } from '../methods/config'; import { getInputs, nodeProperties } from '../methods/config';
@@ -8,24 +8,24 @@ describe('config', () => {
const inputs = getInputs({}); const inputs = getInputs({});
expect(inputs).toHaveLength(3); expect(inputs).toHaveLength(3);
expect(inputs[0].type).toBe(NodeConnectionType.Main); expect(inputs[0].type).toBe(NodeConnectionTypes.Main);
expect(inputs[1].type).toBe(NodeConnectionType.AiLanguageModel); expect(inputs[1].type).toBe(NodeConnectionTypes.AiLanguageModel);
expect(inputs[2].type).toBe(NodeConnectionType.AiOutputParser); expect(inputs[2].type).toBe(NodeConnectionTypes.AiOutputParser);
}); });
it('should exclude the OutputParser when hasOutputParser is false', () => { it('should exclude the OutputParser when hasOutputParser is false', () => {
const inputs = getInputs({ hasOutputParser: false }); const inputs = getInputs({ hasOutputParser: false });
expect(inputs).toHaveLength(2); expect(inputs).toHaveLength(2);
expect(inputs[0].type).toBe(NodeConnectionType.Main); expect(inputs[0].type).toBe(NodeConnectionTypes.Main);
expect(inputs[1].type).toBe(NodeConnectionType.AiLanguageModel); expect(inputs[1].type).toBe(NodeConnectionTypes.AiLanguageModel);
}); });
it('should include the OutputParser when hasOutputParser is true', () => { it('should include the OutputParser when hasOutputParser is true', () => {
const inputs = getInputs({ hasOutputParser: true }); const inputs = getInputs({ hasOutputParser: true });
expect(inputs).toHaveLength(3); expect(inputs).toHaveLength(3);
expect(inputs[2].type).toBe(NodeConnectionType.AiOutputParser); expect(inputs[2].type).toBe(NodeConnectionTypes.AiOutputParser);
}); });
}); });

View File

@@ -8,7 +8,7 @@ import {
import type { BaseRetriever } from '@langchain/core/retrievers'; import type { BaseRetriever } from '@langchain/core/retrievers';
import { createStuffDocumentsChain } from 'langchain/chains/combine_documents'; import { createStuffDocumentsChain } from 'langchain/chains/combine_documents';
import { createRetrievalChain } from 'langchain/chains/retrieval'; import { createRetrievalChain } from 'langchain/chains/retrieval';
import { NodeConnectionType, NodeOperationError, parseErrorMetadata } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError, parseErrorMetadata } from 'n8n-workflow';
import { import {
type INodeProperties, type INodeProperties,
type IExecuteFunctions, type IExecuteFunctions,
@@ -70,21 +70,21 @@ export class ChainRetrievalQa implements INodeType {
}, },
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [ inputs: [
NodeConnectionType.Main, NodeConnectionTypes.Main,
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
{ {
displayName: 'Retriever', displayName: 'Retriever',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiRetriever, type: NodeConnectionTypes.AiRetriever,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [], credentials: [],
properties: [ properties: [
getTemplateNoticeField(1960), getTemplateNoticeField(1960),
@@ -192,12 +192,12 @@ export class ChainRetrievalQa implements INodeType {
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
try { try {
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;
const retriever = (await this.getInputConnectionData( const retriever = (await this.getInputConnectionData(
NodeConnectionType.AiRetriever, NodeConnectionTypes.AiRetriever,
0, 0,
)) as BaseRetriever; )) as BaseRetriever;

View File

@@ -3,8 +3,8 @@ import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import type { BaseRetriever } from '@langchain/core/retrievers'; import type { BaseRetriever } from '@langchain/core/retrievers';
import { FakeChatModel, FakeLLM, FakeRetriever } from '@langchain/core/utils/testing'; import { FakeChatModel, FakeLLM, FakeRetriever } from '@langchain/core/utils/testing';
import get from 'lodash/get'; import get from 'lodash/get';
import type { IDataObject, IExecuteFunctions } from 'n8n-workflow'; import type { IDataObject, IExecuteFunctions, NodeConnectionType } from 'n8n-workflow';
import { NodeConnectionType, NodeOperationError, UnexpectedError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError, UnexpectedError } from 'n8n-workflow';
import { ChainRetrievalQa } from '../ChainRetrievalQa.node'; import { ChainRetrievalQa } from '../ChainRetrievalQa.node';
@@ -27,10 +27,10 @@ const createExecuteFunctionsMock = (
}; };
}, },
getInputConnectionData(type: NodeConnectionType) { getInputConnectionData(type: NodeConnectionType) {
if (type === NodeConnectionType.AiLanguageModel) { if (type === NodeConnectionTypes.AiLanguageModel) {
return fakeLlm; return fakeLlm;
} }
if (type === NodeConnectionType.AiRetriever) { if (type === NodeConnectionTypes.AiRetriever) {
return fakeRetriever; return fakeRetriever;
} }
return null; return null;

View File

@@ -4,7 +4,7 @@ import { PromptTemplate } from '@langchain/core/prompts';
import type { SummarizationChainParams } from 'langchain/chains'; import type { SummarizationChainParams } from 'langchain/chains';
import { loadSummarizationChain } from 'langchain/chains'; import { loadSummarizationChain } from 'langchain/chains';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeTypeBaseDescription, type INodeTypeBaseDescription,
type IExecuteFunctions, type IExecuteFunctions,
type INodeExecutionData, type INodeExecutionData,
@@ -31,21 +31,21 @@ export class ChainSummarizationV1 implements INodeType {
}, },
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [ inputs: [
NodeConnectionType.Main, NodeConnectionTypes.Main,
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
{ {
displayName: 'Document', displayName: 'Document',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiDocument, type: NodeConnectionTypes.AiDocument,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [], credentials: [],
properties: [ properties: [
getTemplateNoticeField(1951), getTemplateNoticeField(1951),
@@ -167,11 +167,11 @@ export class ChainSummarizationV1 implements INodeType {
const type = this.getNodeParameter('type', 0) as 'map_reduce' | 'stuff' | 'refine'; const type = this.getNodeParameter('type', 0) as 'map_reduce' | 'stuff' | 'refine';
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
| N8nJsonLoader | N8nJsonLoader
| Array<Document<Record<string, unknown>>>; | Array<Document<Record<string, unknown>>>;

View File

@@ -10,8 +10,9 @@ import type {
INodeType, INodeType,
INodeTypeDescription, INodeTypeDescription,
IDataObject, IDataObject,
INodeInputConfiguration,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { N8nBinaryLoader } from '@utils/N8nBinaryLoader'; import { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
import { N8nJsonLoader } from '@utils/N8nJsonLoader'; import { N8nJsonLoader } from '@utils/N8nJsonLoader';
@@ -24,7 +25,7 @@ import { REFINE_PROMPT_TEMPLATE, DEFAULT_PROMPT_TEMPLATE } from '../prompt';
function getInputs(parameters: IDataObject) { function getInputs(parameters: IDataObject) {
const chunkingMode = parameters?.chunkingMode; const chunkingMode = parameters?.chunkingMode;
const operationMode = parameters?.operationMode; const operationMode = parameters?.operationMode;
const inputs = [ const inputs: INodeInputConfiguration[] = [
{ displayName: '', type: 'main' }, { displayName: '', type: 'main' },
{ {
displayName: 'Model', displayName: 'Model',
@@ -69,7 +70,7 @@ export class ChainSummarizationV2 implements INodeType {
}, },
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: `={{ ((parameter) => { ${getInputs.toString()}; return getInputs(parameter) })($parameter) }}`, inputs: `={{ ((parameter) => { ${getInputs.toString()}; return getInputs(parameter) })($parameter) }}`,
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [], credentials: [],
properties: [ properties: [
getTemplateNoticeField(1951), getTemplateNoticeField(1951),
@@ -327,7 +328,7 @@ export class ChainSummarizationV2 implements INodeType {
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
try { try {
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;
@@ -356,7 +357,7 @@ export class ChainSummarizationV2 implements INodeType {
// Use dedicated document loader input to load documents // Use dedicated document loader input to load documents
if (operationMode === 'documentLoader') { if (operationMode === 'documentLoader') {
const documentInput = (await this.getInputConnectionData( const documentInput = (await this.getInputConnectionData(
NodeConnectionType.AiDocument, NodeConnectionTypes.AiDocument,
0, 0,
)) as N8nJsonLoader | Array<Document<Record<string, unknown>>>; )) as N8nJsonLoader | Array<Document<Record<string, unknown>>>;
@@ -390,7 +391,7 @@ export class ChainSummarizationV2 implements INodeType {
// In advanced mode user can connect text splitter node so we just retrieve it // In advanced mode user can connect text splitter node so we just retrieve it
case 'advanced': case 'advanced':
textSplitter = (await this.getInputConnectionData( textSplitter = (await this.getInputConnectionData(
NodeConnectionType.AiTextSplitter, NodeConnectionTypes.AiTextSplitter,
0, 0,
)) as TextSplitter | undefined; )) as TextSplitter | undefined;
break; break;

View File

@@ -3,7 +3,7 @@ import { HumanMessage } from '@langchain/core/messages';
import { ChatPromptTemplate, SystemMessagePromptTemplate } from '@langchain/core/prompts'; import { ChatPromptTemplate, SystemMessagePromptTemplate } from '@langchain/core/prompts';
import type { JSONSchema7 } from 'json-schema'; import type { JSONSchema7 } from 'json-schema';
import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers'; import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers';
import { jsonParse, NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
INodeType, INodeType,
INodeTypeDescription, INodeTypeDescription,
@@ -51,15 +51,15 @@ export class InformationExtractor implements INodeType {
name: 'Information Extractor', name: 'Information Extractor',
}, },
inputs: [ inputs: [
{ displayName: '', type: NodeConnectionType.Main }, { displayName: '', type: NodeConnectionTypes.Main },
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
properties: [ properties: [
{ {
displayName: 'Text', displayName: 'Text',
@@ -222,7 +222,7 @@ export class InformationExtractor implements INodeType {
const items = this.getInputData(); const items = this.getInputData();
const llm = (await this.getInputConnectionData( const llm = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;

View File

@@ -2,7 +2,7 @@ import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import { HumanMessage } from '@langchain/core/messages'; import { HumanMessage } from '@langchain/core/messages';
import { SystemMessagePromptTemplate, ChatPromptTemplate } from '@langchain/core/prompts'; import { SystemMessagePromptTemplate, ChatPromptTemplate } from '@langchain/core/prompts';
import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers'; import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
IDataObject, IDataObject,
IExecuteFunctions, IExecuteFunctions,
@@ -24,7 +24,7 @@ const configuredOutputs = (parameters: INodeParameters, defaultCategories: strin
const categories = (options?.categories as string) ?? defaultCategories; const categories = (options?.categories as string) ?? defaultCategories;
const categoriesArray = categories.split(',').map((cat) => cat.trim()); const categoriesArray = categories.split(',').map((cat) => cat.trim());
const ret = categoriesArray.map((cat) => ({ type: NodeConnectionType.Main, displayName: cat })); const ret = categoriesArray.map((cat) => ({ type: NodeConnectionTypes.Main, displayName: cat }));
return ret; return ret;
}; };
@@ -54,11 +54,11 @@ export class SentimentAnalysis implements INodeType {
name: 'Sentiment Analysis', name: 'Sentiment Analysis',
}, },
inputs: [ inputs: [
{ displayName: '', type: NodeConnectionType.Main }, { displayName: '', type: NodeConnectionTypes.Main },
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
], ],
@@ -140,7 +140,7 @@ export class SentimentAnalysis implements INodeType {
const items = this.getInputData(); const items = this.getInputData();
const llm = (await this.getInputConnectionData( const llm = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;

View File

@@ -2,7 +2,7 @@ import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import { HumanMessage } from '@langchain/core/messages'; import { HumanMessage } from '@langchain/core/messages';
import { SystemMessagePromptTemplate, ChatPromptTemplate } from '@langchain/core/prompts'; import { SystemMessagePromptTemplate, ChatPromptTemplate } from '@langchain/core/prompts';
import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers'; import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers';
import { NodeOperationError, NodeConnectionType } from 'n8n-workflow'; import { NodeOperationError, NodeConnectionTypes } from 'n8n-workflow';
import type { import type {
IDataObject, IDataObject,
IExecuteFunctions, IExecuteFunctions,
@@ -22,9 +22,9 @@ const configuredOutputs = (parameters: INodeParameters) => {
const categories = ((parameters.categories as IDataObject)?.categories as IDataObject[]) ?? []; const categories = ((parameters.categories as IDataObject)?.categories as IDataObject[]) ?? [];
const fallback = (parameters.options as IDataObject)?.fallback as string; const fallback = (parameters.options as IDataObject)?.fallback as string;
const ret = categories.map((cat) => { const ret = categories.map((cat) => {
return { type: NodeConnectionType.Main, displayName: cat.category }; return { type: NodeConnectionTypes.Main, displayName: cat.category };
}); });
if (fallback === 'other') ret.push({ type: NodeConnectionType.Main, displayName: 'Other' }); if (fallback === 'other') ret.push({ type: NodeConnectionTypes.Main, displayName: 'Other' });
return ret; return ret;
}; };
@@ -54,11 +54,11 @@ export class TextClassifier implements INodeType {
name: 'Text Classifier', name: 'Text Classifier',
}, },
inputs: [ inputs: [
{ displayName: '', type: NodeConnectionType.Main }, { displayName: '', type: NodeConnectionTypes.Main },
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
], ],
@@ -167,7 +167,7 @@ export class TextClassifier implements INodeType {
const items = this.getInputData(); const items = this.getInputData();
const llm = (await this.getInputConnectionData( const llm = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;

View File

@@ -4,7 +4,7 @@ import { makeResolverFromLegacyOptions } from '@n8n/vm2';
import { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox'; import { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';
import { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox'; import { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';
import { standardizeOutput } from 'n8n-nodes-base/dist/nodes/Code/utils'; import { standardizeOutput } from 'n8n-nodes-base/dist/nodes/Code/utils';
import { NodeOperationError, NodeConnectionType } from 'n8n-workflow'; import { NodeOperationError, NodeConnectionTypes } from 'n8n-workflow';
import type { import type {
IExecuteFunctions, IExecuteFunctions,
INodeExecutionData, INodeExecutionData,
@@ -24,16 +24,16 @@ const { NODE_FUNCTION_ALLOW_BUILTIN: builtIn, NODE_FUNCTION_ALLOW_EXTERNAL: exte
// TODO: Replace // TODO: Replace
const connectorTypes = { const connectorTypes = {
[NodeConnectionType.AiChain]: 'Chain', [NodeConnectionTypes.AiChain]: 'Chain',
[NodeConnectionType.AiDocument]: 'Document', [NodeConnectionTypes.AiDocument]: 'Document',
[NodeConnectionType.AiEmbedding]: 'Embedding', [NodeConnectionTypes.AiEmbedding]: 'Embedding',
[NodeConnectionType.AiLanguageModel]: 'Language Model', [NodeConnectionTypes.AiLanguageModel]: 'Language Model',
[NodeConnectionType.AiMemory]: 'Memory', [NodeConnectionTypes.AiMemory]: 'Memory',
[NodeConnectionType.AiOutputParser]: 'Output Parser', [NodeConnectionTypes.AiOutputParser]: 'Output Parser',
[NodeConnectionType.AiTextSplitter]: 'Text Splitter', [NodeConnectionTypes.AiTextSplitter]: 'Text Splitter',
[NodeConnectionType.AiTool]: 'Tool', [NodeConnectionTypes.AiTool]: 'Tool',
[NodeConnectionType.AiVectorStore]: 'Vector Store', [NodeConnectionTypes.AiVectorStore]: 'Vector Store',
[NodeConnectionType.Main]: 'Main', [NodeConnectionTypes.Main]: 'Main',
}; };
const defaultCodeExecute = `const { PromptTemplate } = require('@langchain/core/prompts'); const defaultCodeExecute = `const { PromptTemplate } = require('@langchain/core/prompts');
@@ -304,7 +304,7 @@ export class Code implements INodeType {
const outputs = this.getNodeOutputs(); const outputs = this.getNodeOutputs();
const mainOutputs: INodeOutputConfiguration[] = outputs.filter( const mainOutputs: INodeOutputConfiguration[] = outputs.filter(
(output) => output.type === NodeConnectionType.Main, (output) => output.type === NodeConnectionTypes.Main,
); );
const options = { multiOutput: mainOutputs.length !== 1 }; const options = { multiOutput: mainOutputs.length !== 1 };

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { TextSplitter } from '@langchain/textsplitters'; import type { TextSplitter } from '@langchain/textsplitters';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -51,15 +51,15 @@ export class DocumentBinaryInputLoader implements INodeType {
{ {
displayName: 'Text Splitter', displayName: 'Text Splitter',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiTextSplitter, type: NodeConnectionTypes.AiTextSplitter,
required: true, required: true,
}, },
], ],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiDocument], outputs: [NodeConnectionTypes.AiDocument],
outputNames: ['Document'], outputNames: ['Document'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: 'Loader Type', displayName: 'Loader Type',
name: 'loader', name: 'loader',
@@ -179,7 +179,7 @@ export class DocumentBinaryInputLoader implements INodeType {
async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {
this.logger.debug('Supply Data for Binary Input Loader'); this.logger.debug('Supply Data for Binary Input Loader');
const textSplitter = (await this.getInputConnectionData( const textSplitter = (await this.getInputConnectionData(
NodeConnectionType.AiTextSplitter, NodeConnectionTypes.AiTextSplitter,
0, 0,
)) as TextSplitter | undefined; )) as TextSplitter | undefined;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { TextSplitter } from '@langchain/textsplitters'; import type { TextSplitter } from '@langchain/textsplitters';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -49,12 +49,12 @@ export class DocumentDefaultDataLoader implements INodeType {
{ {
displayName: 'Text Splitter', displayName: 'Text Splitter',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiTextSplitter, type: NodeConnectionTypes.AiTextSplitter,
required: true, required: true,
}, },
], ],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiDocument], outputs: [NodeConnectionTypes.AiDocument],
outputNames: ['Document'], outputNames: ['Document'],
properties: [ properties: [
{ {
@@ -286,7 +286,7 @@ export class DocumentDefaultDataLoader implements INodeType {
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
const dataType = this.getNodeParameter('dataType', itemIndex, 'json') as 'json' | 'binary'; const dataType = this.getNodeParameter('dataType', itemIndex, 'json') as 'json' | 'binary';
const textSplitter = (await this.getInputConnectionData( const textSplitter = (await this.getInputConnectionData(
NodeConnectionType.AiTextSplitter, NodeConnectionTypes.AiTextSplitter,
0, 0,
)) as TextSplitter | undefined; )) as TextSplitter | undefined;
const binaryDataKey = this.getNodeParameter('binaryDataKey', itemIndex, '') as string; const binaryDataKey = this.getNodeParameter('binaryDataKey', itemIndex, '') as string;

View File

@@ -2,7 +2,7 @@
import { GithubRepoLoader } from '@langchain/community/document_loaders/web/github'; import { GithubRepoLoader } from '@langchain/community/document_loaders/web/github';
import type { CharacterTextSplitter } from '@langchain/textsplitters'; import type { CharacterTextSplitter } from '@langchain/textsplitters';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -47,15 +47,15 @@ export class DocumentGithubLoader implements INodeType {
{ {
displayName: 'Text Splitter', displayName: 'Text Splitter',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiTextSplitter, type: NodeConnectionTypes.AiTextSplitter,
}, },
], ],
inputNames: ['Text Splitter'], inputNames: ['Text Splitter'],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiDocument], outputs: [NodeConnectionTypes.AiDocument],
outputNames: ['Document'], outputNames: ['Document'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: 'Repository Link', displayName: 'Repository Link',
name: 'repository', name: 'repository',
@@ -106,11 +106,11 @@ export class DocumentGithubLoader implements INodeType {
}; };
const textSplitter = (await this.getInputConnectionData( const textSplitter = (await this.getInputConnectionData(
NodeConnectionType.AiTextSplitter, NodeConnectionTypes.AiTextSplitter,
0, 0,
)) as CharacterTextSplitter | undefined; )) as CharacterTextSplitter | undefined;
const { index } = this.addInputData(NodeConnectionType.AiDocument, [ const { index } = this.addInputData(NodeConnectionTypes.AiDocument, [
[{ json: { repository, branch, ignorePaths, recursive } }], [{ json: { repository, branch, ignorePaths, recursive } }],
]); ]);
const docs = new GithubRepoLoader(repository, { const docs = new GithubRepoLoader(repository, {
@@ -125,7 +125,7 @@ export class DocumentGithubLoader implements INodeType {
? await textSplitter.splitDocuments(await docs.load()) ? await textSplitter.splitDocuments(await docs.load())
: await docs.load(); : await docs.load();
this.addOutputData(NodeConnectionType.AiDocument, index, [[{ json: { loadedDocs } }]]); this.addOutputData(NodeConnectionTypes.AiDocument, index, [[{ json: { loadedDocs } }]]);
return { return {
response: logWrapper(loadedDocs, this), response: logWrapper(loadedDocs, this),
}; };

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { TextSplitter } from '@langchain/textsplitters'; import type { TextSplitter } from '@langchain/textsplitters';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -44,15 +44,15 @@ export class DocumentJsonInputLoader implements INodeType {
{ {
displayName: 'Text Splitter', displayName: 'Text Splitter',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiTextSplitter, type: NodeConnectionTypes.AiTextSplitter,
}, },
], ],
inputNames: ['Text Splitter'], inputNames: ['Text Splitter'],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiDocument], outputs: [NodeConnectionTypes.AiDocument],
outputNames: ['Document'], outputNames: ['Document'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: 'Pointers', displayName: 'Pointers',
name: 'pointers', name: 'pointers',
@@ -82,7 +82,7 @@ export class DocumentJsonInputLoader implements INodeType {
async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {
this.logger.debug('Supply Data for JSON Input Loader'); this.logger.debug('Supply Data for JSON Input Loader');
const textSplitter = (await this.getInputConnectionData( const textSplitter = (await this.getInputConnectionData(
NodeConnectionType.AiTextSplitter, NodeConnectionTypes.AiTextSplitter,
0, 0,
)) as TextSplitter | undefined; )) as TextSplitter | undefined;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { BedrockEmbeddings } from '@langchain/aws'; import { BedrockEmbeddings } from '@langchain/aws';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -45,14 +45,14 @@ export class EmbeddingsAwsBedrock implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
requestDefaults: { requestDefaults: {
ignoreHttpStatusErrors: true, ignoreHttpStatusErrors: true,
baseURL: '=https://bedrock.{{$credentials?.region ?? "eu-central-1"}}.amazonaws.com', baseURL: '=https://bedrock.{{$credentials?.region ?? "eu-central-1"}}.amazonaws.com',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: 'Model', displayName: 'Model',
name: 'model', name: 'model',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { OpenAIEmbeddings } from '@langchain/openai'; import { OpenAIEmbeddings } from '@langchain/openai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -45,10 +45,10 @@ export class EmbeddingsAzureOpenAi implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: 'Model (Deployment) Name', displayName: 'Model (Deployment) Name',
name: 'model', name: 'model',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { CohereEmbeddings } from '@langchain/cohere'; import { CohereEmbeddings } from '@langchain/cohere';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -48,10 +48,10 @@ export class EmbeddingsCohere implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: displayName:
'Each model is using different dimensional density for embeddings. Please make sure to use the same dimensionality for your vector store. The default model is using 768-dimensional embeddings.', 'Each model is using different dimensional density for embeddings. Please make sure to use the same dimensionality for your vector store. The default model is using 768-dimensional embeddings.',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { GoogleGenerativeAIEmbeddings } from '@langchain/google-genai'; import { GoogleGenerativeAIEmbeddings } from '@langchain/google-genai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -48,10 +48,10 @@ export class EmbeddingsGoogleGemini implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: displayName:
'Each model is using different dimensional density for embeddings. Please make sure to use the same dimensionality for your vector store. The default model is using 768-dimensional embeddings.', 'Each model is using different dimensional density for embeddings. Please make sure to use the same dimensionality for your vector store. The default model is using 768-dimensional embeddings.',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { HuggingFaceInferenceEmbeddings } from '@langchain/community/embeddings/hf'; import { HuggingFaceInferenceEmbeddings } from '@langchain/community/embeddings/hf';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -44,10 +44,10 @@ export class EmbeddingsHuggingFaceInference implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: displayName:
'Each model is using different dimensional density for embeddings. Please make sure to use the same dimensionality for your vector store. The default model is using 768-dimensional embeddings.', 'Each model is using different dimensional density for embeddings. Please make sure to use the same dimensionality for your vector store. The default model is using 768-dimensional embeddings.',

View File

@@ -2,7 +2,7 @@
import type { MistralAIEmbeddingsParams } from '@langchain/mistralai'; import type { MistralAIEmbeddingsParams } from '@langchain/mistralai';
import { MistralAIEmbeddings } from '@langchain/mistralai'; import { MistralAIEmbeddings } from '@langchain/mistralai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -46,14 +46,14 @@ export class EmbeddingsMistralCloud implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
requestDefaults: { requestDefaults: {
ignoreHttpStatusErrors: true, ignoreHttpStatusErrors: true,
baseURL: 'https://api.mistral.ai/v1', baseURL: 'https://api.mistral.ai/v1',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
displayName: 'Model', displayName: 'Model',
name: 'model', name: 'model',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { OllamaEmbeddings } from '@langchain/ollama'; import { OllamaEmbeddings } from '@langchain/ollama';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -41,9 +41,9 @@ export class EmbeddingsOllama implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
properties: [getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), ollamaModel], properties: [getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]), ollamaModel],
}; };
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { OpenAIEmbeddings } from '@langchain/openai'; import { OpenAIEmbeddings } from '@langchain/openai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type SupplyData, type SupplyData,
@@ -101,7 +101,7 @@ export class EmbeddingsOpenAi implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiEmbedding], outputs: [NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'], outputNames: ['Embeddings'],
requestDefaults: { requestDefaults: {
ignoreHttpStatusErrors: true, ignoreHttpStatusErrors: true,
@@ -109,7 +109,7 @@ export class EmbeddingsOpenAi implements INodeType {
'={{ $parameter.options?.baseURL?.split("/").slice(0,-1).join("/") || $credentials.url?.split("/").slice(0,-1).join("/") || "https://api.openai.com" }}', '={{ $parameter.options?.baseURL?.split("/").slice(0,-1).join("/") || $credentials.url?.split("/").slice(0,-1).join("/") || "https://api.openai.com" }}',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiVectorStore]), getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),
{ {
...modelParameter, ...modelParameter,
default: 'text-embedding-ada-002', default: 'text-embedding-ada-002',

View File

@@ -3,7 +3,7 @@
import { ChatAnthropic } from '@langchain/anthropic'; import { ChatAnthropic } from '@langchain/anthropic';
import type { LLMResult } from '@langchain/core/outputs'; import type { LLMResult } from '@langchain/core/outputs';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodePropertyOptions, type INodePropertyOptions,
type INodeProperties, type INodeProperties,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -109,7 +109,7 @@ export class LmChatAnthropic implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -118,7 +118,7 @@ export class LmChatAnthropic implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiChain]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiChain]),
{ {
...modelField, ...modelField,
displayOptions: { displayOptions: {

View File

@@ -3,7 +3,7 @@
import type { ChatOllamaInput } from '@langchain/ollama'; import type { ChatOllamaInput } from '@langchain/ollama';
import { ChatOllama } from '@langchain/ollama'; import { ChatOllama } from '@langchain/ollama';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -45,11 +45,11 @@ export class LmChatOllama implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
...ollamaDescription, ...ollamaDescription,
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
ollamaModel, ollamaModel,
ollamaOptions, ollamaOptions,
], ],

View File

@@ -2,7 +2,7 @@
import { ChatOpenAI, type ClientOptions } from '@langchain/openai'; import { ChatOpenAI, type ClientOptions } from '@langchain/openai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -51,7 +51,7 @@ export class LmChatOpenAi implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -65,7 +65,7 @@ export class LmChatOpenAi implements INodeType {
'={{ $parameter.options?.baseURL?.split("/").slice(0,-1).join("/") || $credentials?.url?.split("/").slice(0,-1).join("/") || "https://api.openai.com" }}', '={{ $parameter.options?.baseURL?.split("/").slice(0,-1).join("/") || $credentials?.url?.split("/").slice(0,-1).join("/") || "https://api.openai.com" }}',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: displayName:
'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.', 'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { Cohere } from '@langchain/cohere'; import { Cohere } from '@langchain/cohere';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -42,7 +42,7 @@ export class LmCohere implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -51,7 +51,7 @@ export class LmCohere implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',

View File

@@ -2,7 +2,7 @@
import { Ollama } from '@langchain/community/llms/ollama'; import { Ollama } from '@langchain/community/llms/ollama';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -44,11 +44,11 @@ export class LmOllama implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
...ollamaDescription, ...ollamaDescription,
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
ollamaModel, ollamaModel,
ollamaOptions, ollamaOptions,
], ],

View File

@@ -1,6 +1,6 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { OpenAI, type ClientOptions } from '@langchain/openai'; import { OpenAI, type ClientOptions } from '@langchain/openai';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import type { import type {
INodeType, INodeType,
INodeTypeDescription, INodeTypeDescription,
@@ -53,7 +53,7 @@ export class LmOpenAi implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { HuggingFaceInference } from '@langchain/community/llms/hf'; import { HuggingFaceInference } from '@langchain/community/llms/hf';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -42,7 +42,7 @@ export class LmOpenHuggingFaceInference implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -51,7 +51,7 @@ export class LmOpenHuggingFaceInference implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Model', displayName: 'Model',
name: 'model', name: 'model',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { ChatBedrockConverse } from '@langchain/aws'; import { ChatBedrockConverse } from '@langchain/aws';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -42,7 +42,7 @@ export class LmChatAwsBedrock implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -56,7 +56,7 @@ export class LmChatAwsBedrock implements INodeType {
baseURL: '=https://bedrock.{{$credentials?.region ?? "eu-central-1"}}.amazonaws.com', baseURL: '=https://bedrock.{{$credentials?.region ?? "eu-central-1"}}.amazonaws.com',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiChain]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiChain]),
{ {
displayName: 'Model', displayName: 'Model',
name: 'model', name: 'model',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { AzureChatOpenAI } from '@langchain/openai'; import { AzureChatOpenAI } from '@langchain/openai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -42,7 +42,7 @@ export class LmChatAzureOpenAi implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -51,7 +51,7 @@ export class LmChatAzureOpenAi implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: displayName:
'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.', 'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',

View File

@@ -2,7 +2,7 @@
import { ChatOpenAI, type ClientOptions } from '@langchain/openai'; import { ChatOpenAI, type ClientOptions } from '@langchain/openai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -44,7 +44,7 @@ export class LmChatDeepSeek implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -57,7 +57,7 @@ export class LmChatDeepSeek implements INodeType {
baseURL: '={{ $credentials?.url }}', baseURL: '={{ $credentials?.url }}',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: displayName:
'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.', 'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { SafetySetting } from '@google/generative-ai'; import type { SafetySetting } from '@google/generative-ai';
import { ChatGoogleGenerativeAI } from '@langchain/google-genai'; import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import type { import type {
NodeError, NodeError,
INodeType, INodeType,
@@ -52,7 +52,7 @@ export class LmChatGoogleGemini implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -65,7 +65,7 @@ export class LmChatGoogleGemini implements INodeType {
baseURL: '={{ $credentials.host }}', baseURL: '={{ $credentials.host }}',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Model', displayName: 'Model',
name: 'modelName', name: 'modelName',

View File

@@ -4,7 +4,7 @@ import { ProjectsClient } from '@google-cloud/resource-manager';
import { ChatVertexAI } from '@langchain/google-vertexai'; import { ChatVertexAI } from '@langchain/google-vertexai';
import { formatPrivateKey } from 'n8n-nodes-base/dist/utils/utilities'; import { formatPrivateKey } from 'n8n-nodes-base/dist/utils/utilities';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -50,7 +50,7 @@ export class LmChatGoogleVertex implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -59,7 +59,7 @@ export class LmChatGoogleVertex implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Project ID', displayName: 'Project ID',
name: 'projectId', name: 'projectId',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { ChatGroq } from '@langchain/groq'; import { ChatGroq } from '@langchain/groq';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -42,7 +42,7 @@ export class LmChatGroq implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -54,7 +54,7 @@ export class LmChatGroq implements INodeType {
baseURL: 'https://api.groq.com/openai/v1', baseURL: 'https://api.groq.com/openai/v1',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiChain]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiChain]),
{ {
displayName: 'Model', displayName: 'Model',
name: 'model', name: 'model',

View File

@@ -3,7 +3,7 @@
import type { ChatMistralAIInput } from '@langchain/mistralai'; import type { ChatMistralAIInput } from '@langchain/mistralai';
import { ChatMistralAI } from '@langchain/mistralai'; import { ChatMistralAI } from '@langchain/mistralai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -44,7 +44,7 @@ export class LmChatMistralCloud implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -57,7 +57,7 @@ export class LmChatMistralCloud implements INodeType {
baseURL: 'https://api.mistral.ai/v1', baseURL: 'https://api.mistral.ai/v1',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Model', displayName: 'Model',
name: 'model', name: 'model',

View File

@@ -2,7 +2,7 @@
import { ChatOpenAI, type ClientOptions } from '@langchain/openai'; import { ChatOpenAI, type ClientOptions } from '@langchain/openai';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -43,7 +43,7 @@ export class LmChatOpenRouter implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiLanguageModel], outputs: [NodeConnectionTypes.AiLanguageModel],
outputNames: ['Model'], outputNames: ['Model'],
credentials: [ credentials: [
{ {
@@ -56,7 +56,7 @@ export class LmChatOpenRouter implements INodeType {
baseURL: '={{ $credentials?.url }}', baseURL: '={{ $credentials?.url }}',
}, },
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: displayName:
'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.', 'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',

View File

@@ -11,7 +11,7 @@ import type { LLMResult } from '@langchain/core/outputs';
import { encodingForModel } from '@langchain/core/utils/tiktoken'; import { encodingForModel } from '@langchain/core/utils/tiktoken';
import { pick } from 'lodash'; import { pick } from 'lodash';
import type { IDataObject, ISupplyDataFunctions, JsonObject } from 'n8n-workflow'; import type { IDataObject, ISupplyDataFunctions, JsonObject } from 'n8n-workflow';
import { NodeConnectionType, NodeError, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeError, NodeOperationError } from 'n8n-workflow';
import { logAiEvent } from '@utils/helpers'; import { logAiEvent } from '@utils/helpers';
@@ -35,7 +35,7 @@ export class N8nLlmTracing extends BaseCallbackHandler {
// This is crucial for the handleLLMError handler to work correctly (it should be called before the error is propagated to the root node) // This is crucial for the handleLLMError handler to work correctly (it should be called before the error is propagated to the root node)
awaitHandlers = true; awaitHandlers = true;
connectionType = NodeConnectionType.AiLanguageModel; connectionType = NodeConnectionTypes.AiLanguageModel;
promptTokensEstimate = 0; promptTokensEstimate = 0;

View File

@@ -2,7 +2,7 @@
import type { BufferWindowMemoryInput } from 'langchain/memory'; import type { BufferWindowMemoryInput } from 'langchain/memory';
import { BufferWindowMemory } from 'langchain/memory'; import { BufferWindowMemory } from 'langchain/memory';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -101,10 +101,10 @@ export class MemoryBufferWindow implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiMemory], outputs: [NodeConnectionTypes.AiMemory],
outputNames: ['Memory'], outputNames: ['Memory'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Session Key', displayName: 'Session Key',
name: 'sessionKey', name: 'sessionKey',

View File

@@ -2,7 +2,7 @@
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory'; import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
import type { BaseMessage } from '@langchain/core/messages'; import type { BaseMessage } from '@langchain/core/messages';
import { import {
NodeConnectionType, NodeConnectionTypes,
type IDataObject, type IDataObject,
type IExecuteFunctions, type IExecuteFunctions,
type INodeExecutionData, type INodeExecutionData,
@@ -61,16 +61,16 @@ export class MemoryChatRetriever implements INodeType {
}, },
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [ inputs: [
NodeConnectionType.Main, NodeConnectionTypes.Main,
{ {
displayName: 'Memory', displayName: 'Memory',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiMemory, type: NodeConnectionTypes.AiMemory,
required: true, required: true,
}, },
], ],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
properties: [ properties: [
{ {
displayName: "This node is deprecated. Use 'Chat Memory Manager' node instead.", displayName: "This node is deprecated. Use 'Chat Memory Manager' node instead.",
@@ -91,7 +91,7 @@ export class MemoryChatRetriever implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> { async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
this.logger.debug('Executing Chat Memory Retriever'); this.logger.debug('Executing Chat Memory Retriever');
const memory = (await this.getInputConnectionData(NodeConnectionType.AiMemory, 0)) as const memory = (await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as
| BaseChatMemory | BaseChatMemory
| undefined; | undefined;
const simplifyOutput = this.getNodeParameter('simplifyOutput', 0) as boolean; const simplifyOutput = this.getNodeParameter('simplifyOutput', 0) as boolean;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory'; import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
import { AIMessage, SystemMessage, HumanMessage, type BaseMessage } from '@langchain/core/messages'; import { AIMessage, SystemMessage, HumanMessage, type BaseMessage } from '@langchain/core/messages';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import type { import type {
IDataObject, IDataObject,
IExecuteFunctions, IExecuteFunctions,
@@ -92,11 +92,11 @@ export class MemoryManager implements INodeType {
inputs: [ inputs: [
{ {
displayName: '', displayName: '',
type: NodeConnectionType.Main, type: NodeConnectionTypes.Main,
}, },
{ {
displayName: 'Memory', displayName: 'Memory',
type: NodeConnectionType.AiMemory, type: NodeConnectionTypes.AiMemory,
required: true, required: true,
maxConnections: 1, maxConnections: 1,
}, },
@@ -105,7 +105,7 @@ export class MemoryManager implements INodeType {
outputs: [ outputs: [
{ {
displayName: '', displayName: '',
type: NodeConnectionType.Main, type: NodeConnectionTypes.Main,
}, },
], ],
properties: [ properties: [
@@ -297,7 +297,7 @@ export class MemoryManager implements INodeType {
const items = this.getInputData(); const items = this.getInputData();
const mode = this.getNodeParameter('mode', 0, 'load') as 'load' | 'insert' | 'delete'; const mode = this.getNodeParameter('mode', 0, 'load') as 'load' | 'insert' | 'delete';
const memory = (await this.getInputConnectionData( const memory = (await this.getInputConnectionData(
NodeConnectionType.AiMemory, NodeConnectionTypes.AiMemory,
0, 0,
)) as BaseChatMemory; )) as BaseChatMemory;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { MotorheadMemory } from '@langchain/community/memory/motorhead_memory'; import { MotorheadMemory } from '@langchain/community/memory/motorhead_memory';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -42,7 +42,7 @@ export class MemoryMotorhead implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiMemory], outputs: [NodeConnectionTypes.AiMemory],
outputNames: ['Memory'], outputNames: ['Memory'],
credentials: [ credentials: [
{ {
@@ -51,7 +51,7 @@ export class MemoryMotorhead implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Session ID', displayName: 'Session ID',
name: 'sessionId', name: 'sessionId',

View File

@@ -10,7 +10,7 @@ import type {
INodeTypeDescription, INodeTypeDescription,
SupplyData, SupplyData,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import type pg from 'pg'; import type pg from 'pg';
import { getSessionId } from '@utils/helpers'; import { getSessionId } from '@utils/helpers';
@@ -58,10 +58,10 @@ export class MemoryPostgresChat implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiMemory], outputs: [NodeConnectionTypes.AiMemory],
outputNames: ['Memory'], outputNames: ['Memory'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
sessionIdOption, sessionIdOption,
expressionSessionKeyProperty(1.2), expressionSessionKeyProperty(1.2),
sessionKeyProperty, sessionKeyProperty,

View File

@@ -8,7 +8,7 @@ import {
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
type SupplyData, type SupplyData,
NodeConnectionType, NodeConnectionTypes,
} from 'n8n-workflow'; } from 'n8n-workflow';
import type { RedisClientOptions } from 'redis'; import type { RedisClientOptions } from 'redis';
import { createClient } from 'redis'; import { createClient } from 'redis';
@@ -57,10 +57,10 @@ export class MemoryRedisChat implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiMemory], outputs: [NodeConnectionTypes.AiMemory],
outputNames: ['Memory'], outputNames: ['Memory'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Session Key', displayName: 'Session Key',
name: 'sessionKey', name: 'sessionKey',

View File

@@ -2,7 +2,7 @@
import { XataChatMessageHistory } from '@langchain/community/stores/message/xata'; import { XataChatMessageHistory } from '@langchain/community/stores/message/xata';
import { BaseClient } from '@xata.io/client'; import { BaseClient } from '@xata.io/client';
import { BufferMemory, BufferWindowMemory } from 'langchain/memory'; import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
ISupplyDataFunctions, ISupplyDataFunctions,
INodeType, INodeType,
@@ -50,7 +50,7 @@ export class MemoryXata implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiMemory], outputs: [NodeConnectionTypes.AiMemory],
outputNames: ['Memory'], outputNames: ['Memory'],
credentials: [ credentials: [
{ {
@@ -59,7 +59,7 @@ export class MemoryXata implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Session ID', displayName: 'Session ID',
name: 'sessionId', name: 'sessionId',

View File

@@ -5,7 +5,7 @@ import { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';
import type { InputValues, MemoryVariables } from '@langchain/core/memory'; import type { InputValues, MemoryVariables } from '@langchain/core/memory';
import type { BaseMessage } from '@langchain/core/messages'; import type { BaseMessage } from '@langchain/core/messages';
import { import {
NodeConnectionType, NodeConnectionTypes,
type ISupplyDataFunctions, type ISupplyDataFunctions,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
@@ -58,7 +58,7 @@ export class MemoryZep implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiMemory], outputs: [NodeConnectionTypes.AiMemory],
outputNames: ['Memory'], outputNames: ['Memory'],
credentials: [ credentials: [
{ {
@@ -67,7 +67,7 @@ export class MemoryZep implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Only works with Zep Cloud and Community edition <= v0.27.2', displayName: 'Only works with Zep Cloud and Community edition <= v0.27.2',
name: 'supportedVersions', name: 'supportedVersions',

View File

@@ -1,6 +1,6 @@
import type { BaseLanguageModel } from '@langchain/core/language_models/base'; import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import { PromptTemplate } from '@langchain/core/prompts'; import { PromptTemplate } from '@langchain/core/prompts';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
ISupplyDataFunctions, ISupplyDataFunctions,
INodeType, INodeType,
@@ -47,18 +47,18 @@ export class OutputParserAutofixing implements INodeType {
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
{ {
displayName: 'Output Parser', displayName: 'Output Parser',
maxConnections: 1, maxConnections: 1,
required: true, required: true,
type: NodeConnectionType.AiOutputParser, type: NodeConnectionTypes.AiOutputParser,
}, },
], ],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiOutputParser], outputs: [NodeConnectionTypes.AiOutputParser],
outputNames: ['Output Parser'], outputNames: ['Output Parser'],
properties: [ properties: [
{ {
@@ -68,7 +68,7 @@ export class OutputParserAutofixing implements INodeType {
type: 'notice', type: 'notice',
default: '', default: '',
}, },
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',
@@ -95,11 +95,11 @@ export class OutputParserAutofixing implements INodeType {
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
itemIndex, itemIndex,
)) as BaseLanguageModel; )) as BaseLanguageModel;
const outputParser = (await this.getInputConnectionData( const outputParser = (await this.getInputConnectionData(
NodeConnectionType.AiOutputParser, NodeConnectionTypes.AiOutputParser,
itemIndex, itemIndex,
)) as N8nStructuredOutputParser; )) as N8nStructuredOutputParser;
const prompt = this.getNodeParameter('options.prompt', itemIndex, NAIVE_FIX_PROMPT) as string; const prompt = this.getNodeParameter('options.prompt', itemIndex, NAIVE_FIX_PROMPT) as string;

View File

@@ -5,8 +5,12 @@ import { OutputParserException } from '@langchain/core/output_parsers';
import type { MockProxy } from 'jest-mock-extended'; import type { MockProxy } from 'jest-mock-extended';
import { mock } from 'jest-mock-extended'; import { mock } from 'jest-mock-extended';
import { normalizeItems } from 'n8n-core'; import { normalizeItems } from 'n8n-core';
import type { ISupplyDataFunctions, IWorkflowDataProxyData } from 'n8n-workflow'; import type {
import { ApplicationError, NodeConnectionType, NodeOperationError } from 'n8n-workflow'; ISupplyDataFunctions,
IWorkflowDataProxyData,
NodeConnectionType,
} from 'n8n-workflow';
import { ApplicationError, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
N8nOutputFixingParser, N8nOutputFixingParser,
@@ -34,8 +38,8 @@ describe('OutputParserAutofixing', () => {
thisArg.addInputData.mockReturnValue({ index: 0 }); thisArg.addInputData.mockReturnValue({ index: 0 });
thisArg.addOutputData.mockReturnValue(); thisArg.addOutputData.mockReturnValue();
thisArg.getInputConnectionData.mockImplementation(async (type: NodeConnectionType) => { thisArg.getInputConnectionData.mockImplementation(async (type: NodeConnectionType) => {
if (type === NodeConnectionType.AiLanguageModel) return mockModel; if (type === NodeConnectionTypes.AiLanguageModel) return mockModel;
if (type === NodeConnectionType.AiOutputParser) return mockStructuredOutputParser; if (type === NodeConnectionTypes.AiOutputParser) return mockStructuredOutputParser;
throw new ApplicationError('Unexpected connection type'); throw new ApplicationError('Unexpected connection type');
}); });

View File

@@ -1,6 +1,6 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -39,10 +39,10 @@ export class OutputParserItemList implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiOutputParser], outputs: [NodeConnectionTypes.AiOutputParser],
outputNames: ['Output Parser'], outputNames: ['Output Parser'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',

View File

@@ -6,7 +6,7 @@ import {
type ISupplyDataFunctions, type ISupplyDataFunctions,
type SupplyData, type SupplyData,
NodeOperationError, NodeOperationError,
NodeConnectionType, NodeConnectionTypes,
} from 'n8n-workflow'; } from 'n8n-workflow';
import type { z } from 'zod'; import type { z } from 'zod';
@@ -46,10 +46,10 @@ export class OutputParserStructured implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiOutputParser], outputs: [NodeConnectionTypes.AiOutputParser],
outputNames: ['Output Parser'], outputNames: ['Output Parser'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiChain, NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),
{ ...schemaTypeField, displayOptions: { show: { '@version': [{ _cnd: { gte: 1.2 } }] } } }, { ...schemaTypeField, displayOptions: { show: { '@version': [{ _cnd: { gte: 1.2 } }] } } },
{ {
...jsonSchemaExampleField, ...jsonSchemaExampleField,

View File

@@ -5,7 +5,7 @@ import type { BaseRetriever } from '@langchain/core/retrievers';
import { ContextualCompressionRetriever } from 'langchain/retrievers/contextual_compression'; import { ContextualCompressionRetriever } from 'langchain/retrievers/contextual_compression';
import { LLMChainExtractor } from 'langchain/retrievers/document_compressors/chain_extract'; import { LLMChainExtractor } from 'langchain/retrievers/document_compressors/chain_extract';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -44,13 +44,13 @@ export class RetrieverContextualCompression implements INodeType {
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
{ {
displayName: 'Retriever', displayName: 'Retriever',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiRetriever, type: NodeConnectionTypes.AiRetriever,
required: true, required: true,
}, },
], ],
@@ -58,7 +58,7 @@ export class RetrieverContextualCompression implements INodeType {
{ {
displayName: 'Retriever', displayName: 'Retriever',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiRetriever, type: NodeConnectionTypes.AiRetriever,
}, },
], ],
properties: [], properties: [],
@@ -68,12 +68,12 @@ export class RetrieverContextualCompression implements INodeType {
this.logger.debug('Supplying data for Contextual Compression Retriever'); this.logger.debug('Supplying data for Contextual Compression Retriever');
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
itemIndex, itemIndex,
)) as BaseLanguageModel; )) as BaseLanguageModel;
const baseRetriever = (await this.getInputConnectionData( const baseRetriever = (await this.getInputConnectionData(
NodeConnectionType.AiRetriever, NodeConnectionTypes.AiRetriever,
itemIndex, itemIndex,
)) as BaseRetriever; )) as BaseRetriever;

View File

@@ -4,7 +4,7 @@ import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import type { BaseRetriever } from '@langchain/core/retrievers'; import type { BaseRetriever } from '@langchain/core/retrievers';
import { MultiQueryRetriever } from 'langchain/retrievers/multi_query'; import { MultiQueryRetriever } from 'langchain/retrievers/multi_query';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -44,13 +44,13 @@ export class RetrieverMultiQuery implements INodeType {
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
{ {
displayName: 'Retriever', displayName: 'Retriever',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiRetriever, type: NodeConnectionTypes.AiRetriever,
required: true, required: true,
}, },
], ],
@@ -58,7 +58,7 @@ export class RetrieverMultiQuery implements INodeType {
{ {
displayName: 'Retriever', displayName: 'Retriever',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiRetriever, type: NodeConnectionTypes.AiRetriever,
}, },
], ],
properties: [ properties: [
@@ -89,12 +89,12 @@ export class RetrieverMultiQuery implements INodeType {
const options = this.getNodeParameter('options', itemIndex, {}) as { queryCount?: number }; const options = this.getNodeParameter('options', itemIndex, {}) as { queryCount?: number };
const model = (await this.getInputConnectionData( const model = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
itemIndex, itemIndex,
)) as BaseLanguageModel; )) as BaseLanguageModel;
const baseRetriever = (await this.getInputConnectionData( const baseRetriever = (await this.getInputConnectionData(
NodeConnectionType.AiRetriever, NodeConnectionTypes.AiRetriever,
itemIndex, itemIndex,
)) as BaseRetriever; )) as BaseRetriever;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { VectorStore } from '@langchain/core/vectorstores'; import type { VectorStore } from '@langchain/core/vectorstores';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -40,12 +40,12 @@ export class RetrieverVectorStore implements INodeType {
{ {
displayName: 'Vector Store', displayName: 'Vector Store',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiVectorStore, type: NodeConnectionTypes.AiVectorStore,
required: true, required: true,
}, },
], ],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiRetriever], outputs: [NodeConnectionTypes.AiRetriever],
outputNames: ['Retriever'], outputNames: ['Retriever'],
properties: [ properties: [
{ {
@@ -63,7 +63,7 @@ export class RetrieverVectorStore implements INodeType {
const topK = this.getNodeParameter('topK', itemIndex, 4) as number; const topK = this.getNodeParameter('topK', itemIndex, 4) as number;
const vectorStore = (await this.getInputConnectionData( const vectorStore = (await this.getInputConnectionData(
NodeConnectionType.AiVectorStore, NodeConnectionTypes.AiVectorStore,
itemIndex, itemIndex,
)) as VectorStore; )) as VectorStore;

View File

@@ -4,7 +4,7 @@ import { Document } from '@langchain/core/documents';
import { BaseRetriever, type BaseRetrieverInput } from '@langchain/core/retrievers'; import { BaseRetriever, type BaseRetrieverInput } from '@langchain/core/retrievers';
import type { SetField, SetNodeOptions } from 'n8n-nodes-base/dist/nodes/Set/v2/helpers/interfaces'; import type { SetField, SetNodeOptions } from 'n8n-nodes-base/dist/nodes/Set/v2/helpers/interfaces';
import * as manual from 'n8n-nodes-base/dist/nodes/Set/v2/manual.mode'; import * as manual from 'n8n-nodes-base/dist/nodes/Set/v2/manual.mode';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
IDataObject, IDataObject,
IExecuteWorkflowInfo, IExecuteWorkflowInfo,
@@ -66,7 +66,7 @@ export class RetrieverWorkflow implements INodeType {
{ {
displayName: 'Retriever', displayName: 'Retriever',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiRetriever, type: NodeConnectionTypes.AiRetriever,
}, },
], ],
properties: [ properties: [

View File

@@ -2,7 +2,7 @@
import type { CharacterTextSplitterParams } from '@langchain/textsplitters'; import type { CharacterTextSplitterParams } from '@langchain/textsplitters';
import { CharacterTextSplitter } from '@langchain/textsplitters'; import { CharacterTextSplitter } from '@langchain/textsplitters';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -40,10 +40,10 @@ export class TextSplitterCharacterTextSplitter implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTextSplitter], outputs: [NodeConnectionTypes.AiTextSplitter],
outputNames: ['Text Splitter'], outputNames: ['Text Splitter'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiDocument]), getConnectionHintNoticeField([NodeConnectionTypes.AiDocument]),
{ {
displayName: 'Separator', displayName: 'Separator',
name: 'separator', name: 'separator',

View File

@@ -5,7 +5,7 @@ import type {
} from '@langchain/textsplitters'; } from '@langchain/textsplitters';
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters'; import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -60,10 +60,10 @@ export class TextSplitterRecursiveCharacterTextSplitter implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTextSplitter], outputs: [NodeConnectionTypes.AiTextSplitter],
outputNames: ['Text Splitter'], outputNames: ['Text Splitter'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiDocument]), getConnectionHintNoticeField([NodeConnectionTypes.AiDocument]),
{ {
displayName: 'Chunk Size', displayName: 'Chunk Size',
name: 'chunkSize', name: 'chunkSize',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { TokenTextSplitter } from '@langchain/textsplitters'; import { TokenTextSplitter } from '@langchain/textsplitters';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -39,10 +39,10 @@ export class TextSplitterTokenSplitter implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTextSplitter], outputs: [NodeConnectionTypes.AiTextSplitter],
outputNames: ['Text Splitter'], outputNames: ['Text Splitter'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiDocument]), getConnectionHintNoticeField([NodeConnectionTypes.AiDocument]),
{ {
displayName: 'Chunk Size', displayName: 'Chunk Size',
name: 'chunkSize', name: 'chunkSize',

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { Calculator } from '@langchain/community/tools/calculator'; import { Calculator } from '@langchain/community/tools/calculator';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -40,9 +40,9 @@ export class ToolCalculator implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [getConnectionHintNoticeField([NodeConnectionType.AiAgent])], properties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],
}; };
async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {

View File

@@ -13,7 +13,7 @@ import type {
ExecutionError, ExecutionError,
IDataObject, IDataObject,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { jsonParse, NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import { import {
buildInputSchemaField, buildInputSchemaField,
@@ -54,10 +54,10 @@ export class ToolCode implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: displayName:
'See an example of a conversational agent with custom tool written in JavaScript <a href="/templates/1963" target="_blank">here</a>.', 'See an example of a conversational agent with custom tool written in JavaScript <a href="/templates/1963" target="_blank">here</a>.',
@@ -221,7 +221,7 @@ export class ToolCode implements INodeType {
}; };
const toolHandler = async (query: string | IDataObject): Promise<string> => { const toolHandler = async (query: string | IDataObject): Promise<string> => {
const { index } = this.addInputData(NodeConnectionType.AiTool, [[{ json: { query } }]]); const { index } = this.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);
let response: string = ''; let response: string = '';
let executionError: ExecutionError | undefined; let executionError: ExecutionError | undefined;
@@ -245,9 +245,9 @@ export class ToolCode implements INodeType {
} }
if (executionError) { if (executionError) {
void this.addOutputData(NodeConnectionType.AiTool, index, executionError); void this.addOutputData(NodeConnectionTypes.AiTool, index, executionError);
} else { } else {
void this.addOutputData(NodeConnectionType.AiTool, index, [[{ json: { response } }]]); void this.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);
} }
return response; return response;

View File

@@ -8,7 +8,11 @@ import type {
IHttpRequestMethods, IHttpRequestMethods,
IHttpRequestOptions, IHttpRequestOptions,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeConnectionType, NodeOperationError, tryToParseAlphanumericString } from 'n8n-workflow'; import {
NodeConnectionTypes,
NodeOperationError,
tryToParseAlphanumericString,
} from 'n8n-workflow';
import { N8nTool } from '@utils/N8nTool'; import { N8nTool } from '@utils/N8nTool';
import { getConnectionHintNoticeField } from '@utils/sharedFields'; import { getConnectionHintNoticeField } from '@utils/sharedFields';
@@ -62,10 +66,10 @@ export class ToolHttpRequest implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Description', displayName: 'Description',
name: 'toolDescription', name: 'toolDescription',

View File

@@ -14,7 +14,7 @@ import type {
NodeApiError, NodeApiError,
ISupplyDataFunctions, ISupplyDataFunctions,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeConnectionType, NodeOperationError, jsonParse } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError, jsonParse } from 'n8n-workflow';
import { z } from 'zod'; import { z } from 'zod';
import type { import type {
@@ -585,7 +585,7 @@ export const configureToolFunction = (
optimizeResponse: (response: string) => string, optimizeResponse: (response: string) => string,
) => { ) => {
return async (query: string | IDataObject): Promise<string> => { return async (query: string | IDataObject): Promise<string> => {
const { index } = ctx.addInputData(NodeConnectionType.AiTool, [[{ json: { query } }]]); const { index } = ctx.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);
// Clone options and rawRequestOptions to avoid mutating the original objects // Clone options and rawRequestOptions to avoid mutating the original objects
const options: IHttpRequestOptions | null = structuredClone(requestOptions); const options: IHttpRequestOptions | null = structuredClone(requestOptions);
@@ -792,9 +792,9 @@ export const configureToolFunction = (
} }
if (executionError) { if (executionError) {
void ctx.addOutputData(NodeConnectionType.AiTool, index, executionError as ExecutionError); void ctx.addOutputData(NodeConnectionTypes.AiTool, index, executionError as ExecutionError);
} else { } else {
void ctx.addOutputData(NodeConnectionType.AiTool, index, [[{ json: { response } }]]); void ctx.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);
} }
return response; return response;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { SerpAPI } from '@langchain/community/tools/serpapi'; import { SerpAPI } from '@langchain/community/tools/serpapi';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -39,7 +39,7 @@ export class ToolSerpApi implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
credentials: [ credentials: [
{ {
@@ -48,7 +48,7 @@ export class ToolSerpApi implements INodeType {
}, },
], ],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',

View File

@@ -8,7 +8,7 @@ import type {
ISupplyDataFunctions, ISupplyDataFunctions,
SupplyData, SupplyData,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { logWrapper } from '@utils/logWrapper'; import { logWrapper } from '@utils/logWrapper';
import { getConnectionHintNoticeField } from '@utils/sharedFields'; import { getConnectionHintNoticeField } from '@utils/sharedFields';
@@ -44,21 +44,21 @@ export class ToolVectorStore implements INodeType {
{ {
displayName: 'Vector Store', displayName: 'Vector Store',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiVectorStore, type: NodeConnectionTypes.AiVectorStore,
required: true, required: true,
}, },
{ {
displayName: 'Model', displayName: 'Model',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiLanguageModel, type: NodeConnectionTypes.AiLanguageModel,
required: true, required: true,
}, },
], ],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: 'Data Name', displayName: 'Data Name',
name: 'name', name: 'name',
@@ -97,12 +97,12 @@ export class ToolVectorStore implements INodeType {
const topK = this.getNodeParameter('topK', itemIndex, 4) as number; const topK = this.getNodeParameter('topK', itemIndex, 4) as number;
const vectorStore = (await this.getInputConnectionData( const vectorStore = (await this.getInputConnectionData(
NodeConnectionType.AiVectorStore, NodeConnectionTypes.AiVectorStore,
itemIndex, itemIndex,
)) as VectorStore; )) as VectorStore;
const llm = (await this.getInputConnectionData( const llm = (await this.getInputConnectionData(
NodeConnectionType.AiLanguageModel, NodeConnectionTypes.AiLanguageModel,
0, 0,
)) as BaseLanguageModel; )) as BaseLanguageModel;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { WikipediaQueryRun } from '@langchain/community/tools/wikipedia_query_run'; import { WikipediaQueryRun } from '@langchain/community/tools/wikipedia_query_run';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -39,9 +39,9 @@ export class ToolWikipedia implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [getConnectionHintNoticeField([NodeConnectionType.AiAgent])], properties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],
}; };
async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha'; import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -45,9 +45,9 @@ export class ToolWolframAlpha implements INodeType {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [getConnectionHintNoticeField([NodeConnectionType.AiAgent])], properties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],
}; };
async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {

View File

@@ -20,7 +20,7 @@ import type {
ITaskMetadata, ITaskMetadata,
INodeTypeBaseDescription, INodeTypeBaseDescription,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeConnectionType, NodeOperationError, jsonParse } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError, jsonParse } from 'n8n-workflow';
import { versionDescription } from './versionDescription'; import { versionDescription } from './versionDescription';
import type { DynamicZodObject } from '../../../../types/zod.types'; import type { DynamicZodObject } from '../../../../types/zod.types';
@@ -148,7 +148,7 @@ export class ToolWorkflowV1 implements INodeType {
query: string | IDataObject, query: string | IDataObject,
runManager?: CallbackManagerForToolRun, runManager?: CallbackManagerForToolRun,
): Promise<string> => { ): Promise<string> => {
const { index } = this.addInputData(NodeConnectionType.AiTool, [[{ json: { query } }]]); const { index } = this.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);
let response: string = ''; let response: string = '';
let executionError: ExecutionError | undefined; let executionError: ExecutionError | undefined;
@@ -189,12 +189,12 @@ export class ToolWorkflowV1 implements INodeType {
} }
if (executionError) { if (executionError) {
void this.addOutputData(NodeConnectionType.AiTool, index, executionError, metadata); void this.addOutputData(NodeConnectionTypes.AiTool, index, executionError, metadata);
} else { } else {
// Output always needs to be an object // Output always needs to be an object
// so we try to parse the response as JSON and if it fails we just return the string wrapped in an object // so we try to parse the response as JSON and if it fails we just return the string wrapped in an object
const json = jsonParse<IDataObject>(response, { fallbackValue: { response } }); const json = jsonParse<IDataObject>(response, { fallbackValue: { response } });
void this.addOutputData(NodeConnectionType.AiTool, index, [[{ json }]], metadata); void this.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json }]], metadata);
} }
return response; return response;
}; };

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-filename-against-convention */ /* eslint-disable n8n-nodes-base/node-filename-against-convention */
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { INodeTypeDescription } from 'n8n-workflow'; import type { INodeTypeDescription } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { import {
inputSchemaField, inputSchemaField,
@@ -36,10 +36,10 @@ export const versionDescription: INodeTypeDescription = {
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [], inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: displayName:
'See an example of a workflow to suggest meeting slots using AI <a href="/templates/1953" target="_blank">here</a>.', 'See an example of a workflow to suggest meeting slots using AI <a href="/templates/1953" target="_blank">here</a>.',

View File

@@ -21,7 +21,7 @@ import type {
import { import {
generateZodSchema, generateZodSchema,
jsonParse, jsonParse,
NodeConnectionType, NodeConnectionTypes,
NodeOperationError, NodeOperationError,
parseErrorMetadata, parseErrorMetadata,
traverseNodeParameters, traverseNodeParameters,
@@ -113,7 +113,7 @@ export class WorkflowToolService {
} }
void context.addOutputData( void context.addOutputData(
NodeConnectionType.AiTool, NodeConnectionTypes.AiTool,
localRunIndex, localRunIndex,
[responseData], [responseData],
metadata, metadata,
@@ -126,7 +126,7 @@ export class WorkflowToolService {
const metadata = parseErrorMetadata(error); const metadata = parseErrorMetadata(error);
void context.addOutputData( void context.addOutputData(
NodeConnectionType.AiTool, NodeConnectionTypes.AiTool,
localRunIndex, localRunIndex,
executionError, executionError,
metadata, metadata,

View File

@@ -1,6 +1,6 @@
/* eslint-disable n8n-nodes-base/node-filename-against-convention */ /* eslint-disable n8n-nodes-base/node-filename-against-convention */
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { NodeConnectionType, type INodeTypeDescription } from 'n8n-workflow'; import { NodeConnectionTypes, type INodeTypeDescription } from 'n8n-workflow';
import { getConnectionHintNoticeField } from '../../../../utils/sharedFields'; import { getConnectionHintNoticeField } from '../../../../utils/sharedFields';
@@ -14,10 +14,10 @@ export const versionDescription: INodeTypeDescription = {
}, },
version: [2, 2.1], version: [2, 2.1],
inputs: [], inputs: [],
outputs: [NodeConnectionType.AiTool], outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'], outputNames: ['Tool'],
properties: [ properties: [
getConnectionHintNoticeField([NodeConnectionType.AiAgent]), getConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),
{ {
displayName: displayName:
'See an example of a workflow to suggest meeting slots using AI <a href="/templates/1953" target="_blank">here</a>.', 'See an example of a workflow to suggest meeting slots using AI <a href="/templates/1953" target="_blank">here</a>.',

View File

@@ -1,6 +1,6 @@
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory'; import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
import { pick } from 'lodash'; import { pick } from 'lodash';
import { Node, NodeConnectionType } from 'n8n-workflow'; import { Node, NodeConnectionTypes } from 'n8n-workflow';
import type { import type {
IDataObject, IDataObject,
IWebhookFunctions, IWebhookFunctions,
@@ -70,12 +70,12 @@ export class ChatTrigger extends Node {
{ {
displayName: 'Memory', displayName: 'Memory',
maxConnections: 1, maxConnections: 1,
type: '${NodeConnectionType.AiMemory}', type: '${NodeConnectionTypes.AiMemory}',
required: true, required: true,
} }
]; ];
})() }}`, })() }}`,
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [ credentials: [
{ {
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed // eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
@@ -554,7 +554,7 @@ ${cssVariables}
if (bodyData.action === 'loadPreviousSession') { if (bodyData.action === 'loadPreviousSession') {
if (options?.loadPreviousSession === 'memory') { if (options?.loadPreviousSession === 'memory') {
const memory = (await ctx.getInputConnectionData(NodeConnectionType.AiMemory, 0)) as const memory = (await ctx.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as
| BaseChatMemory | BaseChatMemory
| undefined; | undefined;
const messages = ((await memory?.chatHistory.getMessages()) ?? []) const messages = ((await memory?.chatHistory.getMessages()) ?? [])

View File

@@ -3,7 +3,7 @@ import {
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ITriggerResponse, type ITriggerResponse,
NodeConnectionType, NodeConnectionTypes,
} from 'n8n-workflow'; } from 'n8n-workflow';
export class ManualChatTrigger implements INodeType { export class ManualChatTrigger implements INodeType {
@@ -35,7 +35,7 @@ export class ManualChatTrigger implements INodeType {
}, },
}, },
inputs: [], inputs: [],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
properties: [ properties: [
{ {
displayName: displayName:

View File

@@ -2,7 +2,7 @@
import type { Embeddings } from '@langchain/core/embeddings'; import type { Embeddings } from '@langchain/core/embeddings';
import type { Document } from 'langchain/document'; import type { Document } from 'langchain/document';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeExecutionData, type INodeExecutionData,
type IExecuteFunctions, type IExecuteFunctions,
type INodeType, type INodeType,
@@ -42,21 +42,21 @@ export class VectorStoreInMemoryInsert implements INodeType {
}, },
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [ inputs: [
NodeConnectionType.Main, NodeConnectionTypes.Main,
{ {
displayName: 'Document', displayName: 'Document',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiDocument, type: NodeConnectionTypes.AiDocument,
required: true, required: true,
}, },
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
properties: [ properties: [
{ {
displayName: displayName:
@@ -86,13 +86,13 @@ export class VectorStoreInMemoryInsert implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> { async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData(0); const items = this.getInputData(0);
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;
const memoryKey = this.getNodeParameter('memoryKey', 0) as string; const memoryKey = this.getNodeParameter('memoryKey', 0) as string;
const clearStore = this.getNodeParameter('clearStore', 0) as boolean; const clearStore = this.getNodeParameter('clearStore', 0) as boolean;
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
| N8nJsonLoader | N8nJsonLoader
| Array<Document<Record<string, unknown>>>; | Array<Document<Record<string, unknown>>>;

View File

@@ -1,7 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { Embeddings } from '@langchain/core/embeddings'; import type { Embeddings } from '@langchain/core/embeddings';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -43,11 +43,11 @@ export class VectorStoreInMemoryLoad implements INodeType {
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.AiVectorStore], outputs: [NodeConnectionTypes.AiVectorStore],
outputNames: ['Vector Store'], outputNames: ['Vector Store'],
properties: [ properties: [
{ {
@@ -63,7 +63,7 @@ export class VectorStoreInMemoryLoad implements INodeType {
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> { async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
itemIndex, itemIndex,
)) as Embeddings; )) as Embeddings;

View File

@@ -7,7 +7,7 @@ import {
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type INodeExecutionData, type INodeExecutionData,
NodeConnectionType, NodeConnectionTypes,
} from 'n8n-workflow'; } from 'n8n-workflow';
import type { N8nJsonLoader } from '@utils/N8nJsonLoader'; import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
@@ -51,21 +51,21 @@ export class VectorStorePineconeInsert implements INodeType {
}, },
], ],
inputs: [ inputs: [
NodeConnectionType.Main, NodeConnectionTypes.Main,
{ {
displayName: 'Document', displayName: 'Document',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiDocument, type: NodeConnectionTypes.AiDocument,
required: true, required: true,
}, },
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
properties: [ properties: [
pineconeIndexRLC, pineconeIndexRLC,
{ {
@@ -106,12 +106,12 @@ export class VectorStorePineconeInsert implements INodeType {
const credentials = await this.getCredentials('pineconeApi'); const credentials = await this.getCredentials('pineconeApi');
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
| N8nJsonLoader | N8nJsonLoader
| Array<Document<Record<string, unknown>>>; | Array<Document<Record<string, unknown>>>;
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;

View File

@@ -3,7 +3,7 @@ import type { PineconeStoreParams } from '@langchain/pinecone';
import { PineconeStore } from '@langchain/pinecone'; import { PineconeStore } from '@langchain/pinecone';
import { Pinecone } from '@pinecone-database/pinecone'; import { Pinecone } from '@pinecone-database/pinecone';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -54,11 +54,11 @@ export class VectorStorePineconeLoad implements INodeType {
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.AiVectorStore], outputs: [NodeConnectionTypes.AiVectorStore],
outputNames: ['Vector Store'], outputNames: ['Vector Store'],
properties: [ properties: [
pineconeIndexRLC, pineconeIndexRLC,
@@ -95,7 +95,7 @@ export class VectorStorePineconeLoad implements INodeType {
const credentials = await this.getCredentials('pineconeApi'); const credentials = await this.getCredentials('pineconeApi');
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
itemIndex, itemIndex,
)) as Embeddings; )) as Embeddings;

View File

@@ -7,7 +7,7 @@ import {
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type INodeExecutionData, type INodeExecutionData,
NodeConnectionType, NodeConnectionTypes,
} from 'n8n-workflow'; } from 'n8n-workflow';
import type { N8nJsonLoader } from '@utils/N8nJsonLoader'; import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
@@ -51,21 +51,21 @@ export class VectorStoreSupabaseInsert implements INodeType {
}, },
], ],
inputs: [ inputs: [
NodeConnectionType.Main, NodeConnectionTypes.Main,
{ {
displayName: 'Document', displayName: 'Document',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiDocument, type: NodeConnectionTypes.AiDocument,
required: true, required: true,
}, },
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
properties: [ properties: [
{ {
displayName: displayName:
@@ -102,12 +102,12 @@ export class VectorStoreSupabaseInsert implements INodeType {
const queryName = this.getNodeParameter('queryName', 0) as string; const queryName = this.getNodeParameter('queryName', 0) as string;
const credentials = await this.getCredentials('supabaseApi'); const credentials = await this.getCredentials('supabaseApi');
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
| N8nJsonLoader | N8nJsonLoader
| Array<Document<Record<string, unknown>>>; | Array<Document<Record<string, unknown>>>;
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;
const client = createClient(credentials.host as string, credentials.serviceRole as string); const client = createClient(credentials.host as string, credentials.serviceRole as string);

View File

@@ -7,7 +7,7 @@ import {
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
type SupplyData, type SupplyData,
NodeConnectionType, NodeConnectionTypes,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { getMetadataFiltersValues } from '@utils/helpers'; import { getMetadataFiltersValues } from '@utils/helpers';
@@ -54,11 +54,11 @@ export class VectorStoreSupabaseLoad implements INodeType {
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.AiVectorStore], outputs: [NodeConnectionTypes.AiVectorStore],
outputNames: ['Vector Store'], outputNames: ['Vector Store'],
properties: [ properties: [
supabaseTableNameRLC, supabaseTableNameRLC,
@@ -93,7 +93,7 @@ export class VectorStoreSupabaseLoad implements INodeType {
const credentials = await this.getCredentials('supabaseApi'); const credentials = await this.getCredentials('supabaseApi');
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;

View File

@@ -6,7 +6,7 @@ import {
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type INodeExecutionData, type INodeExecutionData,
NodeConnectionType, NodeConnectionTypes,
} from 'n8n-workflow'; } from 'n8n-workflow';
import type { N8nJsonLoader } from '@utils/N8nJsonLoader'; import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
@@ -47,21 +47,21 @@ export class VectorStoreZepInsert implements INodeType {
}, },
], ],
inputs: [ inputs: [
NodeConnectionType.Main, NodeConnectionTypes.Main,
{ {
displayName: 'Document', displayName: 'Document',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiDocument, type: NodeConnectionTypes.AiDocument,
required: true, required: true,
}, },
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
properties: [ properties: [
{ {
displayName: 'Collection Name', displayName: 'Collection Name',
@@ -117,12 +117,12 @@ export class VectorStoreZepInsert implements INodeType {
apiUrl: string; apiUrl: string;
}>('zepApi'); }>('zepApi');
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as const documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
| N8nJsonLoader | N8nJsonLoader
| Array<Document<Record<string, unknown>>>; | Array<Document<Record<string, unknown>>>;
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;

View File

@@ -2,7 +2,7 @@ import type { IZepConfig } from '@langchain/community/vectorstores/zep';
import { ZepVectorStore } from '@langchain/community/vectorstores/zep'; import { ZepVectorStore } from '@langchain/community/vectorstores/zep';
import type { Embeddings } from '@langchain/core/embeddings'; import type { Embeddings } from '@langchain/core/embeddings';
import { import {
NodeConnectionType, NodeConnectionTypes,
type INodeType, type INodeType,
type INodeTypeDescription, type INodeTypeDescription,
type ISupplyDataFunctions, type ISupplyDataFunctions,
@@ -50,11 +50,11 @@ export class VectorStoreZepLoad implements INodeType {
{ {
displayName: 'Embedding', displayName: 'Embedding',
maxConnections: 1, maxConnections: 1,
type: NodeConnectionType.AiEmbedding, type: NodeConnectionTypes.AiEmbedding,
required: true, required: true,
}, },
], ],
outputs: [NodeConnectionType.AiVectorStore], outputs: [NodeConnectionTypes.AiVectorStore],
outputNames: ['Vector Store'], outputNames: ['Vector Store'],
properties: [ properties: [
{ {
@@ -99,7 +99,7 @@ export class VectorStoreZepLoad implements INodeType {
apiUrl: string; apiUrl: string;
}>('zepApi'); }>('zepApi');
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;

View File

@@ -1,6 +1,6 @@
import type { VectorStore } from '@langchain/core/vectorstores'; import type { VectorStore } from '@langchain/core/vectorstores';
import type { INodeProperties } from 'n8n-workflow'; import type { INodeProperties } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { DEFAULT_OPERATION_MODES } from '../constants'; import { DEFAULT_OPERATION_MODES } from '../constants';
import type { VectorStoreNodeConstructorArgs, NodeOperationMode } from '../types'; import type { VectorStoreNodeConstructorArgs, NodeOperationMode } from '../types';
@@ -178,8 +178,8 @@ describe('Vector Store Utilities', () => {
const retrieveOption = result.find((option) => option.value === 'retrieve'); const retrieveOption = result.find((option) => option.value === 'retrieve');
const retrieveAsToolOption = result.find((option) => option.value === 'retrieve-as-tool'); const retrieveAsToolOption = result.find((option) => option.value === 'retrieve-as-tool');
expect(retrieveOption?.outputConnectionType).toBe(NodeConnectionType.AiVectorStore); expect(retrieveOption?.outputConnectionType).toBe(NodeConnectionTypes.AiVectorStore);
expect(retrieveAsToolOption?.outputConnectionType).toBe(NodeConnectionType.AiTool); expect(retrieveAsToolOption?.outputConnectionType).toBe(NodeConnectionTypes.AiTool);
}); });
}); });
}); });

View File

@@ -1,4 +1,4 @@
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import type { INodePropertyOptions } from 'n8n-workflow'; import type { INodePropertyOptions } from 'n8n-workflow';
import type { NodeOperationMode } from './types'; import type { NodeOperationMode } from './types';
@@ -28,14 +28,14 @@ export const OPERATION_MODE_DESCRIPTIONS: INodePropertyOptions[] = [
value: 'retrieve', value: 'retrieve',
description: 'Retrieve documents from vector store to be used as vector store with AI nodes', description: 'Retrieve documents from vector store to be used as vector store with AI nodes',
action: 'Retrieve documents for Chain/Tool as Vector Store', action: 'Retrieve documents for Chain/Tool as Vector Store',
outputConnectionType: NodeConnectionType.AiVectorStore, outputConnectionType: NodeConnectionTypes.AiVectorStore,
}, },
{ {
name: 'Retrieve Documents (As Tool for AI Agent)', name: 'Retrieve Documents (As Tool for AI Agent)',
value: 'retrieve-as-tool', value: 'retrieve-as-tool',
description: 'Retrieve documents from vector store to be used as tool with AI nodes', description: 'Retrieve documents from vector store to be used as tool with AI nodes',
action: 'Retrieve documents for AI Agent as Tool', action: 'Retrieve documents for AI Agent as Tool',
outputConnectionType: NodeConnectionType.AiTool, outputConnectionType: NodeConnectionTypes.AiTool,
}, },
{ {
name: 'Update Documents', name: 'Update Documents',

View File

@@ -2,7 +2,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import type { Embeddings } from '@langchain/core/embeddings'; import type { Embeddings } from '@langchain/core/embeddings';
import type { VectorStore } from '@langchain/core/vectorstores'; import type { VectorStore } from '@langchain/core/vectorstores';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import type { import type {
IExecuteFunctions, IExecuteFunctions,
INodeExecutionData, INodeExecutionData,
@@ -66,18 +66,18 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
inputs: `={{ inputs: `={{
((parameters) => { ((parameters) => {
const mode = parameters?.mode; const mode = parameters?.mode;
const inputs = [{ displayName: "Embedding", type: "${NodeConnectionType.AiEmbedding}", required: true, maxConnections: 1}] const inputs = [{ displayName: "Embedding", type: "${NodeConnectionTypes.AiEmbedding}", required: true, maxConnections: 1}]
if (mode === 'retrieve-as-tool') { if (mode === 'retrieve-as-tool') {
return inputs; return inputs;
} }
if (['insert', 'load', 'update'].includes(mode)) { if (['insert', 'load', 'update'].includes(mode)) {
inputs.push({ displayName: "", type: "${NodeConnectionType.Main}"}) inputs.push({ displayName: "", type: "${NodeConnectionTypes.Main}"})
} }
if (['insert'].includes(mode)) { if (['insert'].includes(mode)) {
inputs.push({ displayName: "Document", type: "${NodeConnectionType.AiDocument}", required: true, maxConnections: 1}) inputs.push({ displayName: "Document", type: "${NodeConnectionTypes.AiDocument}", required: true, maxConnections: 1})
} }
return inputs return inputs
})($parameter) })($parameter)
@@ -87,13 +87,13 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
const mode = parameters?.mode ?? 'retrieve'; const mode = parameters?.mode ?? 'retrieve';
if (mode === 'retrieve-as-tool') { if (mode === 'retrieve-as-tool') {
return [{ displayName: "Tool", type: "${NodeConnectionType.AiTool}"}] return [{ displayName: "Tool", type: "${NodeConnectionTypes.AiTool}"}]
} }
if (mode === 'retrieve') { if (mode === 'retrieve') {
return [{ displayName: "Vector Store", type: "${NodeConnectionType.AiVectorStore}"}] return [{ displayName: "Vector Store", type: "${NodeConnectionTypes.AiVectorStore}"}]
} }
return [{ displayName: "", type: "${NodeConnectionType.Main}"}] return [{ displayName: "", type: "${NodeConnectionTypes.Main}"}]
})($parameter) })($parameter)
}}`, }}`,
properties: [ properties: [
@@ -106,7 +106,7 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
options: getOperationModeOptions(args), options: getOperationModeOptions(args),
}, },
{ {
...getConnectionHintNoticeField([NodeConnectionType.AiRetriever]), ...getConnectionHintNoticeField([NodeConnectionTypes.AiRetriever]),
displayOptions: { displayOptions: {
show: { show: {
mode: ['retrieve'], mode: ['retrieve'],
@@ -232,7 +232,7 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
// Get the embeddings model connected to this node // Get the embeddings model connected to this node
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;
@@ -274,7 +274,7 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
// Get the embeddings model connected to this node // Get the embeddings model connected to this node
const embeddings = (await this.getInputConnectionData( const embeddings = (await this.getInputConnectionData(
NodeConnectionType.AiEmbedding, NodeConnectionTypes.AiEmbedding,
0, 0,
)) as Embeddings; )) as Embeddings;

View File

@@ -6,7 +6,7 @@ import type { VectorStore } from '@langchain/core/vectorstores';
import type { MockProxy } from 'jest-mock-extended'; import type { MockProxy } from 'jest-mock-extended';
import { mock } from 'jest-mock-extended'; import { mock } from 'jest-mock-extended';
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { logAiEvent } from '@utils/helpers'; import { logAiEvent } from '@utils/helpers';
import type { N8nBinaryLoader } from '@utils/N8nBinaryLoader'; import type { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
@@ -137,7 +137,7 @@ describe('handleInsertOperation', () => {
// Should get document input from connection // Should get document input from connection
expect(mockContext.getInputConnectionData).toHaveBeenCalledWith( expect(mockContext.getInputConnectionData).toHaveBeenCalledWith(
NodeConnectionType.AiDocument, NodeConnectionTypes.AiDocument,
0, 0,
); );

View File

@@ -2,7 +2,7 @@ import type { Document } from '@langchain/core/documents';
import type { Embeddings } from '@langchain/core/embeddings'; import type { Embeddings } from '@langchain/core/embeddings';
import type { VectorStore } from '@langchain/core/vectorstores'; import type { VectorStore } from '@langchain/core/vectorstores';
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import { logAiEvent } from '@utils/helpers'; import { logAiEvent } from '@utils/helpers';
import type { N8nBinaryLoader } from '@utils/N8nBinaryLoader'; import type { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
@@ -23,7 +23,7 @@ export async function handleInsertOperation<T extends VectorStore = VectorStore>
const nodeVersion = context.getNode().typeVersion; const nodeVersion = context.getNode().typeVersion;
// Get the input items and document data // Get the input items and document data
const items = context.getInputData(); const items = context.getInputData();
const documentInput = (await context.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as const documentInput = (await context.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as
| N8nJsonLoader | N8nJsonLoader
| N8nBinaryLoader | N8nBinaryLoader
| Array<Document<Record<string, unknown>>>; | Array<Document<Record<string, unknown>>>;

View File

@@ -12,7 +12,7 @@ import type {
} from 'n8n-workflow'; } from 'n8n-workflow';
import { import {
ApplicationError, ApplicationError,
NodeConnectionType, NodeConnectionTypes,
NodeOperationError, NodeOperationError,
updateDisplayOptions, updateDisplayOptions,
} from 'n8n-workflow'; } from 'n8n-workflow';
@@ -235,7 +235,7 @@ export async function execute(this: IExecuteFunctions, i: number): Promise<INode
nodeVersion >= 1.6 && this.getNodeParameter('memory', i) === 'connector'; nodeVersion >= 1.6 && this.getNodeParameter('memory', i) === 'connector';
const memory = const memory =
useMemoryConnector || nodeVersion < 1.6 useMemoryConnector || nodeVersion < 1.6
? ((await this.getInputConnectionData(NodeConnectionType.AiMemory, 0)) as ? ((await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as
| BufferWindowMemory | BufferWindowMemory
| undefined) | undefined)
: undefined; : undefined;

View File

@@ -1,6 +1,6 @@
/* eslint-disable n8n-nodes-base/node-filename-against-convention */ /* eslint-disable n8n-nodes-base/node-filename-against-convention */
import type { INodeInputConfiguration, INodeTypeDescription } from 'n8n-workflow'; import type { INodeInputConfiguration, INodeTypeDescription } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow';
import * as assistant from './assistant'; import * as assistant from './assistant';
import * as audio from './audio'; import * as audio from './audio';
@@ -50,25 +50,25 @@ const configureNodeInputs = (
) => { ) => {
if (resource === 'assistant' && operation === 'message') { if (resource === 'assistant' && operation === 'message') {
const inputs: INodeInputConfiguration[] = [ const inputs: INodeInputConfiguration[] = [
{ type: NodeConnectionType.Main }, { type: NodeConnectionTypes.Main },
{ type: NodeConnectionType.AiTool, displayName: 'Tools' }, { type: NodeConnectionTypes.AiTool, displayName: 'Tools' },
]; ];
if (memory !== 'threadId') { if (memory !== 'threadId') {
inputs.push({ type: NodeConnectionType.AiMemory, displayName: 'Memory', maxConnections: 1 }); inputs.push({ type: NodeConnectionTypes.AiMemory, displayName: 'Memory', maxConnections: 1 });
} }
return inputs; return inputs;
} }
if (resource === 'text' && operation === 'message') { if (resource === 'text' && operation === 'message') {
if (hideTools === 'hide') { if (hideTools === 'hide') {
return [NodeConnectionType.Main]; return [NodeConnectionTypes.Main];
} }
return [ return [
{ type: NodeConnectionType.Main }, { type: NodeConnectionTypes.Main },
{ type: NodeConnectionType.AiTool, displayName: 'Tools' }, { type: NodeConnectionTypes.AiTool, displayName: 'Tools' },
]; ];
} }
return [NodeConnectionType.Main]; return [NodeConnectionTypes.Main];
}; };
// eslint-disable-next-line n8n-nodes-base/node-class-description-missing-subtitle // eslint-disable-next-line n8n-nodes-base/node-class-description-missing-subtitle
@@ -98,7 +98,7 @@ export const versionDescription: INodeTypeDescription = {
}, },
}, },
inputs: `={{(${configureNodeInputs})($parameter.resource, $parameter.operation, $parameter.hideTools, $parameter.memory ?? undefined)}}`, inputs: `={{(${configureNodeInputs})($parameter.resource, $parameter.operation, $parameter.hideTools, $parameter.memory ?? undefined)}}`,
outputs: [NodeConnectionType.Main], outputs: [NodeConnectionTypes.Main],
credentials: [ credentials: [
{ {
name: 'openAiApi', name: 'openAiApi',

View File

@@ -2,7 +2,7 @@ import type { DynamicStructuredToolInput } from '@langchain/core/tools';
import { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools'; import { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools';
import { StructuredOutputParser } from 'langchain/output_parsers'; import { StructuredOutputParser } from 'langchain/output_parsers';
import type { ISupplyDataFunctions, IDataObject } from 'n8n-workflow'; import type { ISupplyDataFunctions, IDataObject } from 'n8n-workflow';
import { NodeConnectionType, jsonParse, NodeOperationError } from 'n8n-workflow'; import { NodeConnectionTypes, jsonParse, NodeOperationError } from 'n8n-workflow';
import type { ZodTypeAny } from 'zod'; import type { ZodTypeAny } from 'zod';
import { ZodBoolean, ZodNullable, ZodNumber, ZodObject, ZodOptional } from 'zod'; import { ZodBoolean, ZodNullable, ZodNumber, ZodObject, ZodOptional } from 'zod';
@@ -96,8 +96,8 @@ export class N8nTool extends DynamicStructuredTool {
return result; return result;
} catch (e) { } catch (e) {
const { index } = context.addInputData(NodeConnectionType.AiTool, [[{ json: { query } }]]); const { index } = context.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);
void context.addOutputData(NodeConnectionType.AiTool, index, e); void context.addOutputData(NodeConnectionTypes.AiTool, index, e);
return e.toString(); return e.toString();
} }

View File

@@ -4,7 +4,7 @@ import type { BaseLLM } from '@langchain/core/language_models/llms';
import type { BaseMessage } from '@langchain/core/messages'; import type { BaseMessage } from '@langchain/core/messages';
import type { Tool } from '@langchain/core/tools'; import type { Tool } from '@langchain/core/tools';
import type { BaseChatMemory } from 'langchain/memory'; import type { BaseChatMemory } from 'langchain/memory';
import { NodeConnectionType, NodeOperationError, jsonStringify } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError, jsonStringify } from 'n8n-workflow';
import type { import type {
AiEvent, AiEvent,
IDataObject, IDataObject,
@@ -190,7 +190,7 @@ export const getConnectedTools = async (
escapeCurlyBrackets: boolean = false, escapeCurlyBrackets: boolean = false,
) => { ) => {
const connectedTools = const connectedTools =
((await ctx.getInputConnectionData(NodeConnectionType.AiTool, 0)) as Tool[]) || []; ((await ctx.getInputConnectionData(NodeConnectionTypes.AiTool, 0)) as Tool[]) || [];
if (!enforceUniqueNames) return connectedTools; if (!enforceUniqueNames) return connectedTools;

View File

@@ -15,8 +15,9 @@ import type {
INodeExecutionData, INodeExecutionData,
ISupplyDataFunctions, ISupplyDataFunctions,
ITaskMetadata, ITaskMetadata,
NodeConnectionType,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { NodeOperationError, NodeConnectionType, parseErrorMetadata } from 'n8n-workflow'; import { NodeOperationError, NodeConnectionTypes, parseErrorMetadata } from 'n8n-workflow';
import { logAiEvent, isToolsInstance, isBaseChatMemory, isBaseChatMessageHistory } from './helpers'; import { logAiEvent, isToolsInstance, isBaseChatMemory, isBaseChatMessageHistory } from './helpers';
import { N8nBinaryLoader } from './N8nBinaryLoader'; import { N8nBinaryLoader } from './N8nBinaryLoader';
@@ -116,7 +117,7 @@ export function logWrapper(
if (isBaseChatMemory(originalInstance)) { if (isBaseChatMemory(originalInstance)) {
if (prop === 'loadMemoryVariables' && 'loadMemoryVariables' in target) { if (prop === 'loadMemoryVariables' && 'loadMemoryVariables' in target) {
return async (values: InputValues): Promise<MemoryVariables> => { return async (values: InputValues): Promise<MemoryVariables> => {
connectionType = NodeConnectionType.AiMemory; connectionType = NodeConnectionTypes.AiMemory;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { action: 'loadMemoryVariables', values } }], [{ json: { action: 'loadMemoryVariables', values } }],
@@ -139,7 +140,7 @@ export function logWrapper(
}; };
} else if (prop === 'saveContext' && 'saveContext' in target) { } else if (prop === 'saveContext' && 'saveContext' in target) {
return async (input: InputValues, output: OutputValues): Promise<MemoryVariables> => { return async (input: InputValues, output: OutputValues): Promise<MemoryVariables> => {
connectionType = NodeConnectionType.AiMemory; connectionType = NodeConnectionTypes.AiMemory;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { action: 'saveContext', input, output } }], [{ json: { action: 'saveContext', input, output } }],
@@ -168,7 +169,7 @@ export function logWrapper(
if (isBaseChatMessageHistory(originalInstance)) { if (isBaseChatMessageHistory(originalInstance)) {
if (prop === 'getMessages' && 'getMessages' in target) { if (prop === 'getMessages' && 'getMessages' in target) {
return async (): Promise<BaseMessage[]> => { return async (): Promise<BaseMessage[]> => {
connectionType = NodeConnectionType.AiMemory; connectionType = NodeConnectionTypes.AiMemory;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { action: 'getMessages' } }], [{ json: { action: 'getMessages' } }],
]); ]);
@@ -189,7 +190,7 @@ export function logWrapper(
}; };
} else if (prop === 'addMessage' && 'addMessage' in target) { } else if (prop === 'addMessage' && 'addMessage' in target) {
return async (message: BaseMessage): Promise<void> => { return async (message: BaseMessage): Promise<void> => {
connectionType = NodeConnectionType.AiMemory; connectionType = NodeConnectionTypes.AiMemory;
const payload = { action: 'addMessage', message }; const payload = { action: 'addMessage', message };
const { index } = executeFunctions.addInputData(connectionType, [[{ json: payload }]]); const { index } = executeFunctions.addInputData(connectionType, [[{ json: payload }]]);
@@ -214,7 +215,7 @@ export function logWrapper(
query: string, query: string,
config?: Callbacks | BaseCallbackConfig, config?: Callbacks | BaseCallbackConfig,
): Promise<Document[]> => { ): Promise<Document[]> => {
connectionType = NodeConnectionType.AiRetriever; connectionType = NodeConnectionTypes.AiRetriever;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { query, config } }], [{ json: { query, config } }],
]); ]);
@@ -255,7 +256,7 @@ export function logWrapper(
// Docs -> Embeddings // Docs -> Embeddings
if (prop === 'embedDocuments' && 'embedDocuments' in target) { if (prop === 'embedDocuments' && 'embedDocuments' in target) {
return async (documents: string[]): Promise<number[][]> => { return async (documents: string[]): Promise<number[][]> => {
connectionType = NodeConnectionType.AiEmbedding; connectionType = NodeConnectionTypes.AiEmbedding;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { documents } }], [{ json: { documents } }],
]); ]);
@@ -276,7 +277,7 @@ export function logWrapper(
// Query -> Embeddings // Query -> Embeddings
if (prop === 'embedQuery' && 'embedQuery' in target) { if (prop === 'embedQuery' && 'embedQuery' in target) {
return async (query: string): Promise<number[]> => { return async (query: string): Promise<number[]> => {
connectionType = NodeConnectionType.AiEmbedding; connectionType = NodeConnectionTypes.AiEmbedding;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { query } }], [{ json: { query } }],
]); ]);
@@ -303,7 +304,7 @@ export function logWrapper(
// Process All // Process All
if (prop === 'processAll' && 'processAll' in target) { if (prop === 'processAll' && 'processAll' in target) {
return async (items: INodeExecutionData[]): Promise<number[]> => { return async (items: INodeExecutionData[]): Promise<number[]> => {
connectionType = NodeConnectionType.AiDocument; connectionType = NodeConnectionTypes.AiDocument;
const { index } = executeFunctions.addInputData(connectionType, [items]); const { index } = executeFunctions.addInputData(connectionType, [items]);
const response = (await callMethodAsync.call(target, { const response = (await callMethodAsync.call(target, {
@@ -322,7 +323,7 @@ export function logWrapper(
// Process Each // Process Each
if (prop === 'processItem' && 'processItem' in target) { if (prop === 'processItem' && 'processItem' in target) {
return async (item: INodeExecutionData, itemIndex: number): Promise<number[]> => { return async (item: INodeExecutionData, itemIndex: number): Promise<number[]> => {
connectionType = NodeConnectionType.AiDocument; connectionType = NodeConnectionTypes.AiDocument;
const { index } = executeFunctions.addInputData(connectionType, [[item]]); const { index } = executeFunctions.addInputData(connectionType, [[item]]);
const response = (await callMethodAsync.call(target, { const response = (await callMethodAsync.call(target, {
@@ -346,7 +347,7 @@ export function logWrapper(
if (originalInstance instanceof TextSplitter) { if (originalInstance instanceof TextSplitter) {
if (prop === 'splitText' && 'splitText' in target) { if (prop === 'splitText' && 'splitText' in target) {
return async (text: string): Promise<string[]> => { return async (text: string): Promise<string[]> => {
connectionType = NodeConnectionType.AiTextSplitter; connectionType = NodeConnectionTypes.AiTextSplitter;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { textSplitter: text } }], [{ json: { textSplitter: text } }],
]); ]);
@@ -370,7 +371,7 @@ export function logWrapper(
if (isToolsInstance(originalInstance)) { if (isToolsInstance(originalInstance)) {
if (prop === '_call' && '_call' in target) { if (prop === '_call' && '_call' in target) {
return async (query: string): Promise<string> => { return async (query: string): Promise<string> => {
connectionType = NodeConnectionType.AiTool; connectionType = NodeConnectionTypes.AiTool;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { query } }], [{ json: { query } }],
]); ]);
@@ -399,7 +400,7 @@ export function logWrapper(
filter?: BiquadFilterType | undefined, filter?: BiquadFilterType | undefined,
_callbacks?: Callbacks | undefined, _callbacks?: Callbacks | undefined,
): Promise<Document[]> => { ): Promise<Document[]> => {
connectionType = NodeConnectionType.AiVectorStore; connectionType = NodeConnectionTypes.AiVectorStore;
const { index } = executeFunctions.addInputData(connectionType, [ const { index } = executeFunctions.addInputData(connectionType, [
[{ json: { query, k, filter } }], [{ json: { query, k, filter } }],
]); ]);

Some files were not shown because too many files have changed in this diff Show More