@n8n/n8n-nodes-langchain 1.105.2 → 1.106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/credentials/HuggingFaceApi.credentials.js +2 -2
- package/dist/credentials/HuggingFaceApi.credentials.js.map +1 -1
- package/dist/credentials/OllamaApi.credentials.js +18 -1
- package/dist/credentials/OllamaApi.credentials.js.map +1 -1
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js +14 -0
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js +14 -0
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js +14 -0
- package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js +5 -1
- package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js +5 -1
- package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js.map +1 -1
- package/dist/nodes/llms/LMOllama/LmOllama.node.js +5 -1
- package/dist/nodes/llms/LMOllama/LmOllama.node.js.map +1 -1
- package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js +1 -1
- package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js.map +1 -1
- package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js +10 -1
- package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +34 -4
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/templates.js +31 -4
- package/dist/nodes/trigger/ChatTrigger/templates.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/types.js +21 -0
- package/dist/nodes/trigger/ChatTrigger/types.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +2 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -1
- package/dist/types/credentials.json +2 -2
- package/dist/types/nodes.json +14 -14
- package/dist/utils/N8nBinaryLoader.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../credentials/HuggingFaceApi.credentials.ts"],"sourcesContent":["import type {\n\tIAuthenticateGeneric,\n\tICredentialTestRequest,\n\tICredentialType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class HuggingFaceApi implements ICredentialType {\n\tname = 'huggingFaceApi';\n\n\tdisplayName = 'HuggingFaceApi';\n\n\tdocumentationUrl = 'huggingface';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'API Key',\n\t\t\tname: 'apiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\trequired: true,\n\t\t\tdefault: '',\n\t\t},\n\t];\n\n\tauthenticate: IAuthenticateGeneric = {\n\t\ttype: 'generic',\n\t\tproperties: {\n\t\t\theaders: {\n\t\t\t\tAuthorization: '=Bearer {{$credentials.apiKey}}',\n\t\t\t},\n\t\t},\n\t};\n\n\ttest: ICredentialTestRequest = {\n\t\trequest: {\n\t\t\tbaseURL: 'https://
|
|
1
|
+
{"version":3,"sources":["../../credentials/HuggingFaceApi.credentials.ts"],"sourcesContent":["import type {\n\tIAuthenticateGeneric,\n\tICredentialTestRequest,\n\tICredentialType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class HuggingFaceApi implements ICredentialType {\n\tname = 'huggingFaceApi';\n\n\tdisplayName = 'HuggingFaceApi';\n\n\tdocumentationUrl = 'huggingface';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'API Key',\n\t\t\tname: 'apiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\trequired: true,\n\t\t\tdefault: '',\n\t\t},\n\t];\n\n\tauthenticate: IAuthenticateGeneric = {\n\t\ttype: 'generic',\n\t\tproperties: {\n\t\t\theaders: {\n\t\t\t\tAuthorization: '=Bearer {{$credentials.apiKey}}',\n\t\t\t},\n\t\t},\n\t};\n\n\ttest: ICredentialTestRequest = {\n\t\trequest: {\n\t\t\tbaseURL: 'https://huggingface.co',\n\t\t\turl: '/api/whoami-v2',\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,eAA0C;AAAA,EAAhD;AACN,gBAAO;AAEP,uBAAc;AAEd,4BAAmB;AAEnB,sBAAgC;AAAA,MAC/B;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa,EAAE,UAAU,KAAK;AAAA,QAC9B,UAAU;AAAA,QACV,SAAS;AAAA,MACV;AAAA,IACD;AAEA,wBAAqC;AAAA,MACpC,MAAM;AAAA,MACN,YAAY;AAAA,QACX,SAAS;AAAA,UACR,eAAe;AAAA,QAChB;AAAA,MACD;AAAA,IACD;AAEA,gBAA+B;AAAA,MAC9B,SAAS;AAAA,QACR,SAAS;AAAA,QACT,KAAK;AAAA,MACN;AAAA,IACD;AAAA;AACD;","names":[]}
|
|
@@ -33,12 +33,29 @@ class OllamaApi {
|
|
|
33
33
|
required: true,
|
|
34
34
|
type: "string",
|
|
35
35
|
default: "http://localhost:11434"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
displayName: "API Key",
|
|
39
|
+
hint: "When using Ollama behind a proxy with authentication (such as Open WebUI), provide the Bearer token/API key here. This is not required for the default Ollama installation",
|
|
40
|
+
name: "apiKey",
|
|
41
|
+
type: "string",
|
|
42
|
+
typeOptions: { password: true },
|
|
43
|
+
default: "",
|
|
44
|
+
required: false
|
|
36
45
|
}
|
|
37
46
|
];
|
|
47
|
+
this.authenticate = {
|
|
48
|
+
type: "generic",
|
|
49
|
+
properties: {
|
|
50
|
+
headers: {
|
|
51
|
+
Authorization: "=Bearer {{$credentials.apiKey}}"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
38
55
|
this.test = {
|
|
39
56
|
request: {
|
|
40
57
|
baseURL: "={{ $credentials.baseUrl }}",
|
|
41
|
-
url: "/",
|
|
58
|
+
url: "/api/tags",
|
|
42
59
|
method: "GET"
|
|
43
60
|
}
|
|
44
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../credentials/OllamaApi.credentials.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../credentials/OllamaApi.credentials.ts"],"sourcesContent":["import type {\n\tICredentialTestRequest,\n\tICredentialType,\n\tINodeProperties,\n\tIAuthenticateGeneric,\n} from 'n8n-workflow';\n\nexport class OllamaApi implements ICredentialType {\n\tname = 'ollamaApi';\n\n\tdisplayName = 'Ollama';\n\n\tdocumentationUrl = 'ollama';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'Base URL',\n\t\t\tname: 'baseUrl',\n\t\t\trequired: true,\n\t\t\ttype: 'string',\n\t\t\tdefault: 'http://localhost:11434',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'API Key',\n\t\t\thint: 'When using Ollama behind a proxy with authentication (such as Open WebUI), provide the Bearer token/API key here. This is not required for the default Ollama installation',\n\t\t\tname: 'apiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\trequired: false,\n\t\t},\n\t];\n\n\tauthenticate: IAuthenticateGeneric = {\n\t\ttype: 'generic',\n\t\tproperties: {\n\t\t\theaders: {\n\t\t\t\tAuthorization: '=Bearer {{$credentials.apiKey}}',\n\t\t\t},\n\t\t},\n\t};\n\n\ttest: ICredentialTestRequest = {\n\t\trequest: {\n\t\t\tbaseURL: '={{ $credentials.baseUrl }}',\n\t\t\turl: '/api/tags',\n\t\t\tmethod: 'GET',\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,UAAqC;AAAA,EAA3C;AACN,gBAAO;AAEP,uBAAc;AAEd,4BAAmB;AAEnB,sBAAgC;AAAA,MAC/B;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,SAAS;AAAA,MACV;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa,EAAE,UAAU,KAAK;AAAA,QAC9B,SAAS;AAAA,QACT,UAAU;AAAA,MACX;AAAA,IACD;AAEA,wBAAqC;AAAA,MACpC,MAAM;AAAA,MACN,YAAY;AAAA,QACX,SAAS;AAAA,UACR,eAAe;AAAA,QAChB;AAAA,MACD;AAAA,IACD;AAEA,gBAA+B;AAAA,MAC9B,SAAS;AAAA,QACR,SAAS;AAAA,QACT,KAAK;AAAA,QACL,QAAQ;AAAA,MACT;AAAA,IACD;AAAA;AACD;","names":[]}
|
|
@@ -280,6 +280,20 @@ class AgentV1 {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
},
|
|
283
|
+
{
|
|
284
|
+
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
|
285
|
+
displayName: "Get started faster with our",
|
|
286
|
+
name: "preBuiltAgentsCallout",
|
|
287
|
+
type: "callout",
|
|
288
|
+
typeOptions: {
|
|
289
|
+
calloutAction: {
|
|
290
|
+
label: "pre-built agents",
|
|
291
|
+
icon: "bot",
|
|
292
|
+
type: "openPreBuiltAgentsCollection"
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
default: ""
|
|
296
|
+
},
|
|
283
297
|
{
|
|
284
298
|
displayName: "This node is using Agent that has been deprecated. Please switch to using 'Tools Agent' instead.",
|
|
285
299
|
name: "deprecated",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../nodes/agents/Agent/V1/AgentV1.node.ts"],"sourcesContent":["import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tINodeInputConfiguration,\n\tINodeInputFilter,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tINodeProperties,\n\tNodeConnectionType,\n\tINodeTypeBaseDescription,\n} from 'n8n-workflow';\n\nimport { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';\n\nimport { conversationalAgentProperties } from '../agents/ConversationalAgent/description';\nimport { conversationalAgentExecute } from '../agents/ConversationalAgent/execute';\nimport { openAiFunctionsAgentProperties } from '../agents/OpenAiFunctionsAgent/description';\nimport { openAiFunctionsAgentExecute } from '../agents/OpenAiFunctionsAgent/execute';\nimport { planAndExecuteAgentProperties } from '../agents/PlanAndExecuteAgent/description';\nimport { planAndExecuteAgentExecute } from '../agents/PlanAndExecuteAgent/execute';\nimport { reActAgentAgentProperties } from '../agents/ReActAgent/description';\nimport { reActAgentAgentExecute } from '../agents/ReActAgent/execute';\nimport { sqlAgentAgentProperties } from '../agents/SqlAgent/description';\nimport { sqlAgentAgentExecute } from '../agents/SqlAgent/execute';\nimport { toolsAgentProperties } from '../agents/ToolsAgent/V1/description';\nimport { toolsAgentExecute } from '../agents/ToolsAgent/V1/execute';\n\n// Function used in the inputs expression to figure out which inputs to\n// display based on the agent type\nfunction getInputs(\n\tagent:\n\t\t| 'toolsAgent'\n\t\t| 'conversationalAgent'\n\t\t| 'openAiFunctionsAgent'\n\t\t| 'planAndExecuteAgent'\n\t\t| 'reActAgent'\n\t\t| 'sqlAgent',\n\thasOutputParser?: boolean,\n): Array<NodeConnectionType | INodeInputConfiguration> {\n\tinterface SpecialInput {\n\t\ttype: NodeConnectionType;\n\t\tfilter?: INodeInputFilter;\n\t\trequired?: boolean;\n\t}\n\n\tconst getInputData = (\n\t\tinputs: SpecialInput[],\n\t): Array<NodeConnectionType | INodeInputConfiguration> => {\n\t\tconst displayNames: { [key: string]: string } = {\n\t\t\tai_languageModel: 'Model',\n\t\t\tai_memory: 'Memory',\n\t\t\tai_tool: 'Tool',\n\t\t\tai_outputParser: 'Output Parser',\n\t\t};\n\n\t\treturn inputs.map(({ type, filter }) => {\n\t\t\tconst isModelType = type === ('ai_languageModel' as NodeConnectionType);\n\t\t\tlet displayName = type in displayNames ? displayNames[type] : undefined;\n\t\t\tif (\n\t\t\t\tisModelType &&\n\t\t\t\t['openAiFunctionsAgent', 'toolsAgent', 'conversationalAgent'].includes(agent)\n\t\t\t) {\n\t\t\t\tdisplayName = 'Chat Model';\n\t\t\t}\n\t\t\tconst input: INodeInputConfiguration = {\n\t\t\t\ttype,\n\t\t\t\tdisplayName,\n\t\t\t\trequired: isModelType,\n\t\t\t\tmaxConnections: ['ai_languageModel', 'ai_memory', 'ai_outputParser'].includes(type)\n\t\t\t\t\t? 1\n\t\t\t\t\t: undefined,\n\t\t\t};\n\n\t\t\tif (filter) {\n\t\t\t\tinput.filter = filter;\n\t\t\t}\n\n\t\t\treturn input;\n\t\t});\n\t};\n\n\tlet specialInputs: SpecialInput[] = [];\n\n\tif (agent === 'conversationalAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAnthropic',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAwsBedrock',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGroq',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOllama',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleGemini',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleVertex',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatMistralCloud',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatDeepSeek',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenRouter',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatVercelAiGateway',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatXAiGrok',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.modelSelector',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'toolsAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAnthropic',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAwsBedrock',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatMistralCloud',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOllama',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGroq',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleVertex',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleGemini',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatDeepSeek',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenRouter',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatVercelAiGateway',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatXAiGrok',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'openAiFunctionsAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'reActAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'sqlAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'planAndExecuteAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t}\n\n\tif (hasOutputParser === false) {\n\t\tspecialInputs = specialInputs.filter((input) => input.type !== 'ai_outputParser');\n\t}\n\treturn ['main', ...getInputData(specialInputs)];\n}\n\nconst agentTypeProperty: INodeProperties = {\n\tdisplayName: 'Agent',\n\tname: 'agent',\n\ttype: 'options',\n\tnoDataExpression: true,\n\t// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items\n\toptions: [\n\t\t{\n\t\t\tname: 'Tools Agent',\n\t\t\tvalue: 'toolsAgent',\n\t\t\tdescription:\n\t\t\t\t'Utilizes structured tool schemas for precise and reliable tool selection and execution. Recommended for complex tasks requiring accurate and consistent tool usage, but only usable with models that support tool calling.',\n\t\t},\n\t\t{\n\t\t\tname: 'Conversational Agent',\n\t\t\tvalue: 'conversationalAgent',\n\t\t\tdescription:\n\t\t\t\t'Describes tools in the system prompt and parses JSON responses for tool calls. More flexible but potentially less reliable than the Tools Agent. Suitable for simpler interactions or with models not supporting structured schemas.',\n\t\t},\n\t\t{\n\t\t\tname: 'OpenAI Functions Agent',\n\t\t\tvalue: 'openAiFunctionsAgent',\n\t\t\tdescription:\n\t\t\t\t\"Leverages OpenAI's function calling capabilities to precisely select and execute tools. Excellent for tasks requiring structured outputs when working with OpenAI models.\",\n\t\t},\n\t\t{\n\t\t\tname: 'Plan and Execute Agent',\n\t\t\tvalue: 'planAndExecuteAgent',\n\t\t\tdescription:\n\t\t\t\t'Creates a high-level plan for complex tasks and then executes each step. Suitable for multi-stage problems or when a strategic approach is needed.',\n\t\t},\n\t\t{\n\t\t\tname: 'ReAct Agent',\n\t\t\tvalue: 'reActAgent',\n\t\t\tdescription:\n\t\t\t\t'Combines reasoning and action in an iterative process. Effective for tasks that require careful analysis and step-by-step problem-solving.',\n\t\t},\n\t\t{\n\t\t\tname: 'SQL Agent',\n\t\t\tvalue: 'sqlAgent',\n\t\t\tdescription:\n\t\t\t\t'Specializes in interacting with SQL databases. Ideal for data analysis tasks, generating queries, or extracting insights from structured data.',\n\t\t},\n\t],\n\tdefault: '',\n};\n\nexport class AgentV1 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\tversion: [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9],\n\t\t\t...baseDescription,\n\t\t\tdefaults: {\n\t\t\t\tname: 'AI Agent',\n\t\t\t\tcolor: '#404040',\n\t\t\t},\n\t\t\tinputs: `={{\n\t\t\t\t((agent, hasOutputParser) => {\n\t\t\t\t\t${getInputs.toString()};\n\t\t\t\t\treturn getInputs(agent, hasOutputParser)\n\t\t\t\t})($parameter.agent, $parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true)\n\t\t\t}}`,\n\t\t\toutputs: [NodeConnectionTypes.Main],\n\t\t\tcredentials: [\n\t\t\t\t{\n\t\t\t\t\tname: 'mySql',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttestedBy: 'mysqlConnectionTest',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t\t'/dataSource': ['mysql'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'postgres',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t\t'/dataSource': ['postgres'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Tip: Get a feel for agents with our quick <a href=\"https://docs.n8n.io/advanced-ai/intro-tutorial/\" target=\"_blank\">tutorial</a> or see an <a href=\"/templates/1954\" target=\"_blank\">example</a> of how this node works',\n\t\t\t\t\tname: 'aiAgentStarterCallout',\n\t\t\t\t\ttype: 'callout',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['conversationalAgent', 'toolsAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t\"This node is using Agent that has been deprecated. Please switch to using 'Tools Agent' instead.\",\n\t\t\t\t\tname: 'deprecated',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: [\n\t\t\t\t\t\t\t\t'conversationalAgent',\n\t\t\t\t\t\t\t\t'openAiFunctionsAgent',\n\t\t\t\t\t\t\t\t'planAndExecuteAgent',\n\t\t\t\t\t\t\t\t'reActAgent',\n\t\t\t\t\t\t\t\t'sqlAgent',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Make Conversational Agent the default agent for versions 1.5 and below\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\toptions: agentTypeProperty?.options?.filter(\n\t\t\t\t\t\t(o) => 'value' in o && o.value !== 'toolsAgent',\n\t\t\t\t\t),\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { lte: 1.5 } }] } },\n\t\t\t\t\tdefault: 'conversationalAgent',\n\t\t\t\t},\n\t\t\t\t// Make Tools Agent the default agent for versions 1.6 and 1.7\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { between: { from: 1.6, to: 1.7 } } }] } },\n\t\t\t\t\tdefault: 'toolsAgent',\n\t\t\t\t},\n\t\t\t\t// Make Tools Agent the only agent option for versions 1.8 and above\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\ttype: 'hidden',\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { gte: 1.8 } }] } },\n\t\t\t\t\tdefault: 'toolsAgent',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...promptTypeOptions,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textFromPreviousNode,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: { promptType: ['auto'], '@version': [{ _cnd: { gte: 1.7 } }] },\n\t\t\t\t\t\t// SQL Agent has data source and credentials parameters so we need to include this input there manually\n\t\t\t\t\t\t// to preserve the order\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textInput,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['define'],\n\t\t\t\t\t\t},\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'For more reliable structured output parsing, consider using the Tools agent',\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t\tagent: [\n\t\t\t\t\t\t\t\t'conversationalAgent',\n\t\t\t\t\t\t\t\t'reActAgent',\n\t\t\t\t\t\t\t\t'planAndExecuteAgent',\n\t\t\t\t\t\t\t\t'openAiFunctionsAgent',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Require Specific Output Format',\n\t\t\t\t\tname: 'hasOutputParser',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: `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`,\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t\tagent: ['toolsAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\n\t\t\t\t...toolsAgentProperties,\n\t\t\t\t...conversationalAgentProperties,\n\t\t\t\t...openAiFunctionsAgentProperties,\n\t\t\t\t...reActAgentAgentProperties,\n\t\t\t\t...sqlAgentAgentProperties,\n\t\t\t\t...planAndExecuteAgentProperties,\n\t\t\t],\n\t\t};\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst agentType = this.getNodeParameter('agent', 0, '') as string;\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tif (agentType === 'conversationalAgent') {\n\t\t\treturn await conversationalAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'toolsAgent') {\n\t\t\treturn await toolsAgentExecute.call(this);\n\t\t} else if (agentType === 'openAiFunctionsAgent') {\n\t\t\treturn await openAiFunctionsAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'reActAgent') {\n\t\t\treturn await reActAgentAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'sqlAgent') {\n\t\t\treturn await sqlAgentAgentExecute.call(this);\n\t\t} else if (agentType === 'planAndExecuteAgent') {\n\t\t\treturn await planAndExecuteAgentExecute.call(this, nodeVersion);\n\t\t}\n\n\t\tthrow new NodeOperationError(this.getNode(), `The agent type \"${agentType}\" is not supported`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAwD;AAaxD,0BAAmE;AAEnE,yBAA8C;AAC9C,qBAA2C;AAC3C,IAAAA,sBAA+C;AAC/C,IAAAC,kBAA4C;AAC5C,IAAAD,sBAA8C;AAC9C,IAAAC,kBAA2C;AAC3C,IAAAD,sBAA0C;AAC1C,IAAAC,kBAAuC;AACvC,IAAAD,sBAAwC;AACxC,IAAAC,kBAAqC;AACrC,IAAAD,sBAAqC;AACrC,IAAAC,kBAAkC;AAIlC,SAAS,UACR,OAOA,iBACsD;AAOtD,QAAM,eAAe,CACpB,WACyD;AACzD,UAAM,eAA0C;AAAA,MAC/C,kBAAkB;AAAA,MAClB,WAAW;AAAA,MACX,SAAS;AAAA,MACT,iBAAiB;AAAA,IAClB;AAEA,WAAO,OAAO,IAAI,CAAC,EAAE,MAAM,OAAO,MAAM;AACvC,YAAM,cAAc,SAAU;AAC9B,UAAI,cAAc,QAAQ,eAAe,aAAa,IAAI,IAAI;AAC9D,UACC,eACA,CAAC,wBAAwB,cAAc,qBAAqB,EAAE,S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AAM,WAAW;AAAA,IAC/D,WAAW,cAAc,cAAc;AACtC,aAAO,MAAM,kCAAkB,KAAK,IAAI;AAAA,IACzC,WAAW,cAAc,wBAAwB;AAChD,aAAO,MAAM,4CAA4B,KAAK,MAAM,WAAW;AAAA,IAChE,WAAW,cAAc,cAAc;AACtC,aAAO,MAAM,uCAAuB,KAAK,MAAM,WAAW;AAAA,IAC3D,WAAW,cAAc,YAAY;AACpC,aAAO,MAAM,qCAAqB,KAAK,IAAI;AAAA,IAC5C,WAAW,cAAc,uBAAuB;AAC/C,aAAO,MAAM,2CAA2B,KAAK,MAAM,WAAW;AAAA,IAC/D;AAEA,UAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,mBAAmB,SAAS,oBAAoB;AAAA,EAC9F;AACD;","names":["import_description","import_execute"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/agents/Agent/V1/AgentV1.node.ts"],"sourcesContent":["import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tINodeInputConfiguration,\n\tINodeInputFilter,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tINodeProperties,\n\tNodeConnectionType,\n\tINodeTypeBaseDescription,\n} from 'n8n-workflow';\n\nimport { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';\n\nimport { conversationalAgentProperties } from '../agents/ConversationalAgent/description';\nimport { conversationalAgentExecute } from '../agents/ConversationalAgent/execute';\nimport { openAiFunctionsAgentProperties } from '../agents/OpenAiFunctionsAgent/description';\nimport { openAiFunctionsAgentExecute } from '../agents/OpenAiFunctionsAgent/execute';\nimport { planAndExecuteAgentProperties } from '../agents/PlanAndExecuteAgent/description';\nimport { planAndExecuteAgentExecute } from '../agents/PlanAndExecuteAgent/execute';\nimport { reActAgentAgentProperties } from '../agents/ReActAgent/description';\nimport { reActAgentAgentExecute } from '../agents/ReActAgent/execute';\nimport { sqlAgentAgentProperties } from '../agents/SqlAgent/description';\nimport { sqlAgentAgentExecute } from '../agents/SqlAgent/execute';\nimport { toolsAgentProperties } from '../agents/ToolsAgent/V1/description';\nimport { toolsAgentExecute } from '../agents/ToolsAgent/V1/execute';\n\n// Function used in the inputs expression to figure out which inputs to\n// display based on the agent type\nfunction getInputs(\n\tagent:\n\t\t| 'toolsAgent'\n\t\t| 'conversationalAgent'\n\t\t| 'openAiFunctionsAgent'\n\t\t| 'planAndExecuteAgent'\n\t\t| 'reActAgent'\n\t\t| 'sqlAgent',\n\thasOutputParser?: boolean,\n): Array<NodeConnectionType | INodeInputConfiguration> {\n\tinterface SpecialInput {\n\t\ttype: NodeConnectionType;\n\t\tfilter?: INodeInputFilter;\n\t\trequired?: boolean;\n\t}\n\n\tconst getInputData = (\n\t\tinputs: SpecialInput[],\n\t): Array<NodeConnectionType | INodeInputConfiguration> => {\n\t\tconst displayNames: { [key: string]: string } = {\n\t\t\tai_languageModel: 'Model',\n\t\t\tai_memory: 'Memory',\n\t\t\tai_tool: 'Tool',\n\t\t\tai_outputParser: 'Output Parser',\n\t\t};\n\n\t\treturn inputs.map(({ type, filter }) => {\n\t\t\tconst isModelType = type === ('ai_languageModel' as NodeConnectionType);\n\t\t\tlet displayName = type in displayNames ? displayNames[type] : undefined;\n\t\t\tif (\n\t\t\t\tisModelType &&\n\t\t\t\t['openAiFunctionsAgent', 'toolsAgent', 'conversationalAgent'].includes(agent)\n\t\t\t) {\n\t\t\t\tdisplayName = 'Chat Model';\n\t\t\t}\n\t\t\tconst input: INodeInputConfiguration = {\n\t\t\t\ttype,\n\t\t\t\tdisplayName,\n\t\t\t\trequired: isModelType,\n\t\t\t\tmaxConnections: ['ai_languageModel', 'ai_memory', 'ai_outputParser'].includes(type)\n\t\t\t\t\t? 1\n\t\t\t\t\t: undefined,\n\t\t\t};\n\n\t\t\tif (filter) {\n\t\t\t\tinput.filter = filter;\n\t\t\t}\n\n\t\t\treturn input;\n\t\t});\n\t};\n\n\tlet specialInputs: SpecialInput[] = [];\n\n\tif (agent === 'conversationalAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAnthropic',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAwsBedrock',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGroq',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOllama',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleGemini',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleVertex',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatMistralCloud',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatDeepSeek',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenRouter',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatVercelAiGateway',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatXAiGrok',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.modelSelector',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'toolsAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAnthropic',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAwsBedrock',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatMistralCloud',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOllama',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGroq',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleVertex',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatGoogleGemini',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatDeepSeek',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenRouter',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatVercelAiGateway',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatXAiGrok',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'openAiFunctionsAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t\tfilter: {\n\t\t\t\t\tnodes: [\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatOpenAi',\n\t\t\t\t\t\t'@n8n/n8n-nodes-langchain.lmChatAzureOpenAi',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'reActAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'sqlAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_memory',\n\t\t\t},\n\t\t];\n\t} else if (agent === 'planAndExecuteAgent') {\n\t\tspecialInputs = [\n\t\t\t{\n\t\t\t\ttype: 'ai_languageModel',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_tool',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'ai_outputParser',\n\t\t\t},\n\t\t];\n\t}\n\n\tif (hasOutputParser === false) {\n\t\tspecialInputs = specialInputs.filter((input) => input.type !== 'ai_outputParser');\n\t}\n\treturn ['main', ...getInputData(specialInputs)];\n}\n\nconst agentTypeProperty: INodeProperties = {\n\tdisplayName: 'Agent',\n\tname: 'agent',\n\ttype: 'options',\n\tnoDataExpression: true,\n\t// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items\n\toptions: [\n\t\t{\n\t\t\tname: 'Tools Agent',\n\t\t\tvalue: 'toolsAgent',\n\t\t\tdescription:\n\t\t\t\t'Utilizes structured tool schemas for precise and reliable tool selection and execution. Recommended for complex tasks requiring accurate and consistent tool usage, but only usable with models that support tool calling.',\n\t\t},\n\t\t{\n\t\t\tname: 'Conversational Agent',\n\t\t\tvalue: 'conversationalAgent',\n\t\t\tdescription:\n\t\t\t\t'Describes tools in the system prompt and parses JSON responses for tool calls. More flexible but potentially less reliable than the Tools Agent. Suitable for simpler interactions or with models not supporting structured schemas.',\n\t\t},\n\t\t{\n\t\t\tname: 'OpenAI Functions Agent',\n\t\t\tvalue: 'openAiFunctionsAgent',\n\t\t\tdescription:\n\t\t\t\t\"Leverages OpenAI's function calling capabilities to precisely select and execute tools. Excellent for tasks requiring structured outputs when working with OpenAI models.\",\n\t\t},\n\t\t{\n\t\t\tname: 'Plan and Execute Agent',\n\t\t\tvalue: 'planAndExecuteAgent',\n\t\t\tdescription:\n\t\t\t\t'Creates a high-level plan for complex tasks and then executes each step. Suitable for multi-stage problems or when a strategic approach is needed.',\n\t\t},\n\t\t{\n\t\t\tname: 'ReAct Agent',\n\t\t\tvalue: 'reActAgent',\n\t\t\tdescription:\n\t\t\t\t'Combines reasoning and action in an iterative process. Effective for tasks that require careful analysis and step-by-step problem-solving.',\n\t\t},\n\t\t{\n\t\t\tname: 'SQL Agent',\n\t\t\tvalue: 'sqlAgent',\n\t\t\tdescription:\n\t\t\t\t'Specializes in interacting with SQL databases. Ideal for data analysis tasks, generating queries, or extracting insights from structured data.',\n\t\t},\n\t],\n\tdefault: '',\n};\n\nexport class AgentV1 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\tversion: [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9],\n\t\t\t...baseDescription,\n\t\t\tdefaults: {\n\t\t\t\tname: 'AI Agent',\n\t\t\t\tcolor: '#404040',\n\t\t\t},\n\t\t\tinputs: `={{\n\t\t\t\t((agent, hasOutputParser) => {\n\t\t\t\t\t${getInputs.toString()};\n\t\t\t\t\treturn getInputs(agent, hasOutputParser)\n\t\t\t\t})($parameter.agent, $parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true)\n\t\t\t}}`,\n\t\t\toutputs: [NodeConnectionTypes.Main],\n\t\t\tcredentials: [\n\t\t\t\t{\n\t\t\t\t\tname: 'mySql',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttestedBy: 'mysqlConnectionTest',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t\t'/dataSource': ['mysql'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'postgres',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t\t'/dataSource': ['postgres'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Tip: Get a feel for agents with our quick <a href=\"https://docs.n8n.io/advanced-ai/intro-tutorial/\" target=\"_blank\">tutorial</a> or see an <a href=\"/templates/1954\" target=\"_blank\">example</a> of how this node works',\n\t\t\t\t\tname: 'aiAgentStarterCallout',\n\t\t\t\t\ttype: 'callout',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: ['conversationalAgent', 'toolsAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\t\tdisplayName: 'Get started faster with our',\n\t\t\t\t\tname: 'preBuiltAgentsCallout',\n\t\t\t\t\ttype: 'callout',\n\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\tcalloutAction: {\n\t\t\t\t\t\t\tlabel: 'pre-built agents',\n\t\t\t\t\t\t\ticon: 'bot',\n\t\t\t\t\t\t\ttype: 'openPreBuiltAgentsCollection',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tdefault: '',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t\"This node is using Agent that has been deprecated. Please switch to using 'Tools Agent' instead.\",\n\t\t\t\t\tname: 'deprecated',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tagent: [\n\t\t\t\t\t\t\t\t'conversationalAgent',\n\t\t\t\t\t\t\t\t'openAiFunctionsAgent',\n\t\t\t\t\t\t\t\t'planAndExecuteAgent',\n\t\t\t\t\t\t\t\t'reActAgent',\n\t\t\t\t\t\t\t\t'sqlAgent',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Make Conversational Agent the default agent for versions 1.5 and below\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\toptions: agentTypeProperty?.options?.filter(\n\t\t\t\t\t\t(o) => 'value' in o && o.value !== 'toolsAgent',\n\t\t\t\t\t),\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { lte: 1.5 } }] } },\n\t\t\t\t\tdefault: 'conversationalAgent',\n\t\t\t\t},\n\t\t\t\t// Make Tools Agent the default agent for versions 1.6 and 1.7\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { between: { from: 1.6, to: 1.7 } } }] } },\n\t\t\t\t\tdefault: 'toolsAgent',\n\t\t\t\t},\n\t\t\t\t// Make Tools Agent the only agent option for versions 1.8 and above\n\t\t\t\t{\n\t\t\t\t\t...agentTypeProperty,\n\t\t\t\t\ttype: 'hidden',\n\t\t\t\t\tdisplayOptions: { show: { '@version': [{ _cnd: { gte: 1.8 } }] } },\n\t\t\t\t\tdefault: 'toolsAgent',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...promptTypeOptions,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textFromPreviousNode,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: { promptType: ['auto'], '@version': [{ _cnd: { gte: 1.7 } }] },\n\t\t\t\t\t\t// SQL Agent has data source and credentials parameters so we need to include this input there manually\n\t\t\t\t\t\t// to preserve the order\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textInput,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['define'],\n\t\t\t\t\t\t},\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'For more reliable structured output parsing, consider using the Tools agent',\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t\tagent: [\n\t\t\t\t\t\t\t\t'conversationalAgent',\n\t\t\t\t\t\t\t\t'reActAgent',\n\t\t\t\t\t\t\t\t'planAndExecuteAgent',\n\t\t\t\t\t\t\t\t'openAiFunctionsAgent',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Require Specific Output Format',\n\t\t\t\t\tname: 'hasOutputParser',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tagent: ['sqlAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: `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`,\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t\tagent: ['toolsAgent'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\n\t\t\t\t...toolsAgentProperties,\n\t\t\t\t...conversationalAgentProperties,\n\t\t\t\t...openAiFunctionsAgentProperties,\n\t\t\t\t...reActAgentAgentProperties,\n\t\t\t\t...sqlAgentAgentProperties,\n\t\t\t\t...planAndExecuteAgentProperties,\n\t\t\t],\n\t\t};\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst agentType = this.getNodeParameter('agent', 0, '') as string;\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tif (agentType === 'conversationalAgent') {\n\t\t\treturn await conversationalAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'toolsAgent') {\n\t\t\treturn await toolsAgentExecute.call(this);\n\t\t} else if (agentType === 'openAiFunctionsAgent') {\n\t\t\treturn await openAiFunctionsAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'reActAgent') {\n\t\t\treturn await reActAgentAgentExecute.call(this, nodeVersion);\n\t\t} else if (agentType === 'sqlAgent') {\n\t\t\treturn await sqlAgentAgentExecute.call(this);\n\t\t} else if (agentType === 'planAndExecuteAgent') {\n\t\t\treturn await planAndExecuteAgentExecute.call(this, nodeVersion);\n\t\t}\n\n\t\tthrow new NodeOperationError(this.getNode(), `The agent type \"${agentType}\" is not supported`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAwD;AAaxD,0BAAmE;AAEnE,yBAA8C;AAC9C,qBAA2C;AAC3C,IAAAA,sBAA+C;AAC/C,IAAAC,kBAA4C;AAC5C,IAAAD,sBAA8C;AAC9C,IAAAC,kBAA2C;AAC3C,IAAAD,sBAA0C;AAC1C,IAAAC,kBAAuC;AACvC,IAAAD,sBAAwC;AACxC,IAAAC,kBAAqC;AACrC,IAAAD,sBAAqC;AACrC,IAAAC,kBAAkC;AAIlC,SAAS,UACR,OAOA,iBACsD;AAOtD,QAAM,eAAe,CACpB,WACyD;AACzD,UAAM,eAA0C;AAAA,MAC/C,kBAAkB;AAAA,MAClB,WAAW;AAAA,MACX,SAAS;AAAA,MACT,iBAAiB;AAAA,IAClB;AAEA,WAAO,OAAO,IAAI,CAAC,EAAE,MAAM,OAAO,MAAM;AACvC,YAAM,cAAc,SAAU;AAC9B,UAAI,cAAc,QAAQ,eAAe,aAAa,IAAI,IAAI;AAC9D,UACC,eACA,CAAC,wBAAwB,cAAc,qBAAqB,EAAE,SAAS,KAAK,GAC3E;AACD,sBAAc;AAAA,MACf;AACA,YAAM,QAAiC;AAAA,QACtC;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV,gBAAgB,CAAC,oBAAoB,aAAa,iBAAiB,EAAE,SAAS,IAAI,IAC/E,IACA;AAAA,MACJ;AAEA,UAAI,QAAQ;AACX,cAAM,SAAS;AAAA,MAChB;AAEA,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAEA,MAAI,gBAAgC,CAAC;AAErC,MAAI,UAAU,uBAAuB;AACpC,oBAAgB;AAAA,MACf;AAAA,QACC,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,OAAO;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA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C,aAAO,MAAM,qCAAqB,KAAK,IAAI;AAAA,IAC5C,WAAW,cAAc,uBAAuB;AAC/C,aAAO,MAAM,2CAA2B,KAAK,MAAM,WAAW;AAAA,IAC/D;AAEA,UAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,mBAAmB,SAAS,oBAAoB;AAAA,EAC9F;AACD;","names":["import_description","import_execute"]}
|
|
@@ -49,6 +49,20 @@ class AgentV2 {
|
|
|
49
49
|
type: "callout",
|
|
50
50
|
default: ""
|
|
51
51
|
},
|
|
52
|
+
{
|
|
53
|
+
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
|
54
|
+
displayName: "Get started faster with our",
|
|
55
|
+
name: "preBuiltAgentsCallout",
|
|
56
|
+
type: "callout",
|
|
57
|
+
typeOptions: {
|
|
58
|
+
calloutAction: {
|
|
59
|
+
label: "pre-built agents",
|
|
60
|
+
icon: "bot",
|
|
61
|
+
type: "openPreBuiltAgentsCollection"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
default: ""
|
|
65
|
+
},
|
|
52
66
|
import_descriptions.promptTypeOptions,
|
|
53
67
|
{
|
|
54
68
|
...import_descriptions.textFromPreviousNode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../nodes/agents/Agent/V2/AgentV2.node.ts"],"sourcesContent":["import { NodeConnectionTypes } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tINodeTypeBaseDescription,\n} from 'n8n-workflow';\n\nimport { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';\n\nimport { getInputs } from './utils';\nimport { getToolsAgentProperties } from '../agents/ToolsAgent/V2/description';\nimport { toolsAgentExecute } from '../agents/ToolsAgent/V2/execute';\n\nexport class AgentV2 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\t...baseDescription,\n\t\t\tversion: [2, 2.1, 2.2],\n\t\t\tdefaults: {\n\t\t\t\tname: 'AI Agent',\n\t\t\t\tcolor: '#404040',\n\t\t\t},\n\t\t\tinputs: `={{\n\t\t\t\t((hasOutputParser, needsFallback) => {\n\t\t\t\t\t${getInputs.toString()};\n\t\t\t\t\treturn getInputs(true, hasOutputParser, needsFallback);\n\t\t\t\t})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true, $parameter.needsFallback !== undefined && $parameter.needsFallback === true)\n\t\t\t}}`,\n\t\t\toutputs: [NodeConnectionTypes.Main],\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Tip: Get a feel for agents with our quick <a href=\"https://docs.n8n.io/advanced-ai/intro-tutorial/\" target=\"_blank\">tutorial</a> or see an <a href=\"/workflows/templates/1954\" target=\"_blank\">example</a> of how this node works',\n\t\t\t\t\tname: 'aiAgentStarterCallout',\n\t\t\t\t\ttype: 'callout',\n\t\t\t\t\tdefault: '',\n\t\t\t\t},\n\t\t\t\tpromptTypeOptions,\n\t\t\t\t{\n\t\t\t\t\t...textFromPreviousNode,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['auto'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textInput,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['define'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Require Specific Output Format',\n\t\t\t\t\tname: 'hasOutputParser',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: `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`,\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Enable Fallback Model',\n\t\t\t\t\tname: 'needsFallback',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 2.1 } }],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Connect an additional language model on the canvas to use it as a fallback if the main model fails',\n\t\t\t\t\tname: 'fallbackNotice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tneedsFallback: [true],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...getToolsAgentProperties({ withStreaming: true }),\n\t\t\t],\n\t\t\thints: [\n\t\t\t\t{\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'You are using streaming responses. Make sure to set the response mode to \"Streaming Response\" on the connected trigger node.',\n\t\t\t\t\ttype: 'warning',\n\t\t\t\t\tlocation: 'outputPane',\n\t\t\t\t\twhenToDisplay: 'afterExecution',\n\t\t\t\t\tdisplayCondition: '={{ $parameter[\"enableStreaming\"] === true }}',\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tre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AAAA,UACT,kBAAkB;AAAA,UAClB,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAAA,QACA;AAAA,UACC,aACC;AAAA,UACD,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,eAAe,CAAC,IAAI;AAAA,YACrB;AAAA,UACD;AAAA,QACD;AAAA,QACA,OAAG,4CAAwB,EAAE,eAAe,KAAK,CAAC;AAAA,MACnD;AAAA,MACA,OAAO;AAAA,QACN;AAAA,UACC,SACC;AAAA,UACD,MAAM;AAAA,UACN,UAAU;AAAA,UACV,eAAe;AAAA,UACf,kBAAkB;AAAA,QACnB;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM,UAAkE;AACvE,WAAO,MAAM,iCAAkB,KAAK,IAAI;AAAA,EACzC;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/agents/Agent/V2/AgentV2.node.ts"],"sourcesContent":["import { NodeConnectionTypes } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tINodeTypeBaseDescription,\n} from 'n8n-workflow';\n\nimport { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';\n\nimport { getInputs } from './utils';\nimport { getToolsAgentProperties } from '../agents/ToolsAgent/V2/description';\nimport { toolsAgentExecute } from '../agents/ToolsAgent/V2/execute';\n\nexport class AgentV2 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\t...baseDescription,\n\t\t\tversion: [2, 2.1, 2.2],\n\t\t\tdefaults: {\n\t\t\t\tname: 'AI Agent',\n\t\t\t\tcolor: '#404040',\n\t\t\t},\n\t\t\tinputs: `={{\n\t\t\t\t((hasOutputParser, needsFallback) => {\n\t\t\t\t\t${getInputs.toString()};\n\t\t\t\t\treturn getInputs(true, hasOutputParser, needsFallback);\n\t\t\t\t})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true, $parameter.needsFallback !== undefined && $parameter.needsFallback === true)\n\t\t\t}}`,\n\t\t\toutputs: [NodeConnectionTypes.Main],\n\t\t\tproperties: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Tip: Get a feel for agents with our quick <a href=\"https://docs.n8n.io/advanced-ai/intro-tutorial/\" target=\"_blank\">tutorial</a> or see an <a href=\"/workflows/templates/1954\" target=\"_blank\">example</a> of how this node works',\n\t\t\t\t\tname: 'aiAgentStarterCallout',\n\t\t\t\t\ttype: 'callout',\n\t\t\t\t\tdefault: '',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\t\tdisplayName: 'Get started faster with our',\n\t\t\t\t\tname: 'preBuiltAgentsCallout',\n\t\t\t\t\ttype: 'callout',\n\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\tcalloutAction: {\n\t\t\t\t\t\t\tlabel: 'pre-built agents',\n\t\t\t\t\t\t\ticon: 'bot',\n\t\t\t\t\t\t\ttype: 'openPreBuiltAgentsCollection',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tdefault: '',\n\t\t\t\t},\n\t\t\t\tpromptTypeOptions,\n\t\t\t\t{\n\t\t\t\t\t...textFromPreviousNode,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['auto'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...textInput,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tpromptType: ['define'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Require Specific Output Format',\n\t\t\t\t\tname: 'hasOutputParser',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: `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`,\n\t\t\t\t\tname: 'notice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\thasOutputParser: [true],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Enable Fallback Model',\n\t\t\t\t\tname: 'needsFallback',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 2.1 } }],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName:\n\t\t\t\t\t\t'Connect an additional language model on the canvas to use it as a fallback if the main model fails',\n\t\t\t\t\tname: 'fallbackNotice',\n\t\t\t\t\ttype: 'notice',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tneedsFallback: [true],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...getToolsAgentProperties({ withStreaming: true }),\n\t\t\t],\n\t\t\thints: [\n\t\t\t\t{\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'You are using streaming responses. Make sure to set the response mode to \"Streaming Response\" on the connected trigger node.',\n\t\t\t\t\ttype: 'warning',\n\t\t\t\t\tlocation: 'outputPane',\n\t\t\t\t\twhenToDisplay: 'afterExecution',\n\t\t\t\t\tdisplayCondition: '={{ $parameter[\"enableStreaming\"] === true }}',\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\treturn await toolsAgentExecute.call(this);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoC;AASpC,0BAAmE;AAEnE,mBAA0B;AAC1B,yBAAwC;AACxC,qBAAkC;AAE3B,MAAM,QAA6B;AAAA,EAGzC,YAAY,iBAA2C;AACtD,SAAK,cAAc;AAAA,MAClB,GAAG;AAAA,MACH,SAAS,CAAC,GAAG,KAAK,GAAG;AAAA,MACrB,UAAU;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,MACA,QAAQ;AAAA;AAAA,OAEJ,uBAAU,SAAS,CAAC;AAAA;AAAA;AAAA;AAAA,MAIxB,SAAS,CAAC,wCAAoB,IAAI;AAAA,MAClC,YAAY;AAAA,QACX;AAAA,UACC,aACC;AAAA,UACD,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,QACA;AAAA;AAAA,UAEC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,aAAa;AAAA,YACZ,eAAe;AAAA,cACd,OAAO;AAAA,cACP,MAAM;AAAA,cACN,MAAM;AAAA,YACP;AAAA,UACD;AAAA,UACA,SAAS;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,UACC,GAAG;AAAA,UACH,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,YAAY,CAAC,MAAM;AAAA,YACpB;AAAA,UACD;AAAA,QACD;AAAA,QACA;AAAA,UACC,GAAG;AAAA,UACH,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,YAAY,CAAC,QAAQ;AAAA,YACtB;AAAA,UACD;AAAA,QACD;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,kBAAkB;AAAA,QACnB;AAAA,QACA;AAAA,UACC,aAAa,8FAA8F,wCAAoB,cAAc;AAAA,UAC7I,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,iBAAiB,CAAC,IAAI;AAAA,YACvB;AAAA,UACD;AAAA,QACD;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,kBAAkB;AAAA,UAClB,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAAA,QACA;AAAA,UACC,aACC;AAAA,UACD,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,eAAe,CAAC,IAAI;AAAA,YACrB;AAAA,UACD;AAAA,QACD;AAAA,QACA,OAAG,4CAAwB,EAAE,eAAe,KAAK,CAAC;AAAA,MACnD;AAAA,MACA,OAAO;AAAA,QACN;AAAA,UACC,SACC;AAAA,UACD,MAAM;AAAA,UACN,UAAU;AAAA,UACV,eAAe;AAAA,UACf,kBAAkB;AAAA,QACnB;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM,UAAkE;AACvE,WAAO,MAAM,iCAAkB,KAAK,IAAI;AAAA,EACzC;AACD;","names":[]}
|
package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(EmbeddingsHuggingFaceInference_node_exports, {
|
|
|
21
21
|
EmbeddingsHuggingFaceInference: () => EmbeddingsHuggingFaceInference
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(EmbeddingsHuggingFaceInference_node_exports);
|
|
24
|
+
var import_inference = require("@huggingface/inference");
|
|
24
25
|
var import_hf = require("@langchain/community/embeddings/hf");
|
|
25
26
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
27
|
var import_logWrapper = require("../../../utils/logWrapper");
|
|
@@ -88,6 +89,13 @@ class EmbeddingsHuggingFaceInference {
|
|
|
88
89
|
default: "",
|
|
89
90
|
description: "Custom endpoint URL",
|
|
90
91
|
type: "string"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
displayName: "Provider",
|
|
95
|
+
name: "provider",
|
|
96
|
+
type: "options",
|
|
97
|
+
options: import_inference.PROVIDERS_OR_POLICIES.map((value) => ({ value, name: value })),
|
|
98
|
+
default: "auto"
|
|
91
99
|
}
|
|
92
100
|
]
|
|
93
101
|
}
|
|
@@ -103,6 +111,9 @@ class EmbeddingsHuggingFaceInference {
|
|
|
103
111
|
);
|
|
104
112
|
const credentials = await this.getCredentials("huggingFaceApi");
|
|
105
113
|
const options = this.getNodeParameter("options", itemIndex, {});
|
|
114
|
+
if ("provider" in options && !isValidHFProviderOrPolicy(options.provider)) {
|
|
115
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Unsupported provider");
|
|
116
|
+
}
|
|
106
117
|
const embeddings = new import_hf.HuggingFaceInferenceEmbeddings({
|
|
107
118
|
apiKey: credentials.apiKey,
|
|
108
119
|
model,
|
|
@@ -113,6 +124,9 @@ class EmbeddingsHuggingFaceInference {
|
|
|
113
124
|
};
|
|
114
125
|
}
|
|
115
126
|
}
|
|
127
|
+
function isValidHFProviderOrPolicy(provider) {
|
|
128
|
+
return typeof provider === "string" && import_inference.PROVIDERS_OR_POLICIES.includes(provider);
|
|
129
|
+
}
|
|
116
130
|
// Annotate the CommonJS export names for ESM import in node:
|
|
117
131
|
0 && (module.exports = {
|
|
118
132
|
EmbeddingsHuggingFaceInference
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.ts"],"sourcesContent":["import { HuggingFaceInferenceEmbeddings } from '@langchain/community/embeddings/hf';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class EmbeddingsHuggingFaceInference implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings Hugging Face Inference',\n\t\tname: 'embeddingsHuggingFaceInference',\n\t\ticon: 'file:huggingface.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Use HuggingFace Inference Embeddings',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings HuggingFace Inference',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'huggingFaceApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingshuggingfaceinference/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'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.',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model Name',\n\t\t\t\tname: 'modelName',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'sentence-transformers/distilbert-base-nli-mean-tokens',\n\t\t\t\tdescription: 'The model name to use from HuggingFace library',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Custom Inference Endpoint',\n\t\t\t\t\t\tname: 'endpointUrl',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tdescription: 'Custom endpoint URL',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings HF Inference');\n\t\tconst model = this.getNodeParameter(\n\t\t\t'modelName',\n\t\t\titemIndex,\n\t\t\t'sentence-transformers/distilbert-base-nli-mean-tokens',\n\t\t) as string;\n\t\tconst credentials = await this.getCredentials('huggingFaceApi');\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as object;\n\n\t\tconst embeddings = new HuggingFaceInferenceEmbeddings({\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\tmodel,\n\t\t\t...options,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.ts"],"sourcesContent":["import type { InferenceProviderOrPolicy } from '@huggingface/inference';\nimport { PROVIDERS_OR_POLICIES } from '@huggingface/inference';\nimport { HuggingFaceInferenceEmbeddings } from '@langchain/community/embeddings/hf';\nimport {\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class EmbeddingsHuggingFaceInference implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings Hugging Face Inference',\n\t\tname: 'embeddingsHuggingFaceInference',\n\t\ticon: 'file:huggingface.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Use HuggingFace Inference Embeddings',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings HuggingFace Inference',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'huggingFaceApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingshuggingfaceinference/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'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.',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model Name',\n\t\t\t\tname: 'modelName',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'sentence-transformers/distilbert-base-nli-mean-tokens',\n\t\t\t\tdescription: 'The model name to use from HuggingFace library',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Custom Inference Endpoint',\n\t\t\t\t\t\tname: 'endpointUrl',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tdescription: 'Custom endpoint URL',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Provider',\n\t\t\t\t\t\tname: 'provider',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: PROVIDERS_OR_POLICIES.map((value) => ({ value, name: value })),\n\t\t\t\t\t\tdefault: 'auto',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings HF Inference');\n\t\tconst model = this.getNodeParameter(\n\t\t\t'modelName',\n\t\t\titemIndex,\n\t\t\t'sentence-transformers/distilbert-base-nli-mean-tokens',\n\t\t) as string;\n\t\tconst credentials = await this.getCredentials('huggingFaceApi');\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as object;\n\n\t\tif ('provider' in options && !isValidHFProviderOrPolicy(options.provider)) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Unsupported provider');\n\t\t}\n\n\t\tconst embeddings = new HuggingFaceInferenceEmbeddings({\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\tmodel,\n\t\t\t...options,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n\nfunction isValidHFProviderOrPolicy(provider: unknown): provider is InferenceProviderOrPolicy {\n\treturn (\n\t\ttypeof provider === 'string' && (PROVIDERS_OR_POLICIES as readonly string[]).includes(provider)\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAsC;AACtC,gBAA+C;AAC/C,0BAOO;AAEP,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,+BAAoD;AAAA,EAA1D;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,YAAY;AAAA,QAClB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,WAAW;AAAA,MACzC,aAAa,CAAC,YAAY;AAAA,MAC1B,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,aAAa,CAAC;AAAA,QAChE;AAAA,UACC,aACC;AAAA,UACD,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS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@ class EmbeddingsOllama {
|
|
|
62
62
|
this.logger.debug("Supply data for embeddings Ollama");
|
|
63
63
|
const modelName = this.getNodeParameter("model", itemIndex);
|
|
64
64
|
const credentials = await this.getCredentials("ollamaApi");
|
|
65
|
+
const headers = credentials.apiKey ? {
|
|
66
|
+
Authorization: `Bearer ${credentials.apiKey}`
|
|
67
|
+
} : void 0;
|
|
65
68
|
const embeddings = new import_ollama.OllamaEmbeddings({
|
|
66
69
|
baseUrl: credentials.baseUrl,
|
|
67
|
-
model: modelName
|
|
70
|
+
model: modelName,
|
|
71
|
+
headers
|
|
68
72
|
});
|
|
69
73
|
return {
|
|
70
74
|
response: (0, import_logWrapper.logWrapper)(embeddings, this)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.ts"],"sourcesContent":["import { OllamaEmbeddings } from '@langchain/ollama';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { ollamaDescription, ollamaModel } from '../../llms/LMOllama/description';\n\nexport class EmbeddingsOllama implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings Ollama',\n\t\tname: 'embeddingsOllama',\n\t\ticon: 'file:ollama.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Use Ollama Embeddings',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings Ollama',\n\t\t},\n\t\t...ollamaDescription,\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsollama/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\tproperties: [getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]), ollamaModel],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings Ollama');\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst credentials = await this.getCredentials('ollamaApi');\n\n\t\tconst embeddings = new OllamaEmbeddings({\n\t\t\tbaseUrl: credentials.baseUrl as string,\n\t\t\tmodel: modelName,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAE7C,yBAA+C;AAExC,MAAM,iBAAsC;AAAA,EAA5C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,GAAG;AAAA,MACH,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,YAAY;AAAA,QAClB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,WAAW;AAAA,MACzC,aAAa,CAAC,YAAY;AAAA,MAC1B,YAAY,KAAC,kDAA6B,CAAC,wCAAoB,aAAa,CAAC,GAAG,8BAAW;AAAA,IAC5F;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,SAAK,OAAO,MAAM,mCAAmC;AACrD,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,cAAc,MAAM,KAAK,eAAe,WAAW;
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.ts"],"sourcesContent":["import { OllamaEmbeddings } from '@langchain/ollama';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { ollamaDescription, ollamaModel } from '../../llms/LMOllama/description';\n\nexport class EmbeddingsOllama implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings Ollama',\n\t\tname: 'embeddingsOllama',\n\t\ticon: 'file:ollama.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Use Ollama Embeddings',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings Ollama',\n\t\t},\n\t\t...ollamaDescription,\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsollama/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\tproperties: [getConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]), ollamaModel],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings Ollama');\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst credentials = await this.getCredentials('ollamaApi');\n\t\tconst headers = credentials.apiKey\n\t\t\t? {\n\t\t\t\t\tAuthorization: `Bearer ${credentials.apiKey as string}`,\n\t\t\t\t}\n\t\t\t: undefined;\n\n\t\tconst embeddings = new OllamaEmbeddings({\n\t\t\tbaseUrl: credentials.baseUrl as string,\n\t\t\tmodel: modelName,\n\t\t\theaders,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAE7C,yBAA+C;AAExC,MAAM,iBAAsC;AAAA,EAA5C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,GAAG;AAAA,MACH,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,YAAY;AAAA,QAClB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,WAAW;AAAA,MACzC,aAAa,CAAC,YAAY;AAAA,MAC1B,YAAY,KAAC,kDAA6B,CAAC,wCAAoB,aAAa,CAAC,GAAG,8BAAW;AAAA,IAC5F;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,SAAK,OAAO,MAAM,mCAAmC;AACrD,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,cAAc,MAAM,KAAK,eAAe,WAAW;AACzD,UAAM,UAAU,YAAY,SACzB;AAAA,MACA,eAAe,UAAU,YAAY,MAAgB;AAAA,IACtD,IACC;AAEH,UAAM,aAAa,IAAI,+BAAiB;AAAA,MACvC,SAAS,YAAY;AAAA,MACrB,OAAO;AAAA,MACP;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,YAAY,IAAI;AAAA,IACtC;AAAA,EACD;AACD;","names":[]}
|
|
@@ -68,13 +68,17 @@ class LmChatOllama {
|
|
|
68
68
|
const credentials = await this.getCredentials("ollamaApi");
|
|
69
69
|
const modelName = this.getNodeParameter("model", itemIndex);
|
|
70
70
|
const options = this.getNodeParameter("options", itemIndex, {});
|
|
71
|
+
const headers = credentials.apiKey ? {
|
|
72
|
+
Authorization: `Bearer ${credentials.apiKey}`
|
|
73
|
+
} : void 0;
|
|
71
74
|
const model = new import_ollama.ChatOllama({
|
|
72
75
|
...options,
|
|
73
76
|
baseUrl: credentials.baseUrl,
|
|
74
77
|
model: modelName,
|
|
75
78
|
format: options.format === "default" ? void 0 : options.format,
|
|
76
79
|
callbacks: [new import_N8nLlmTracing.N8nLlmTracing(this)],
|
|
77
|
-
onFailedAttempt: (0, import_n8nLlmFailedAttemptHandler.makeN8nLlmFailedAttemptHandler)(this)
|
|
80
|
+
onFailedAttempt: (0, import_n8nLlmFailedAttemptHandler.makeN8nLlmFailedAttemptHandler)(this),
|
|
81
|
+
headers
|
|
78
82
|
});
|
|
79
83
|
return {
|
|
80
84
|
response: model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/llms/LMChatOllama/LmChatOllama.node.ts"],"sourcesContent":["import type { ChatOllamaInput } from '@langchain/ollama';\nimport { ChatOllama } from '@langchain/ollama';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { ollamaModel, ollamaOptions, ollamaDescription } from '../LMOllama/description';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmChatOllama implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Ollama Chat Model',\n\n\t\tname: 'lmChatOllama',\n\t\ticon: 'file:ollama.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Language Model Ollama',\n\t\tdefaults: {\n\t\t\tname: 'Ollama Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatollama/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\t...ollamaDescription,\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\tollamaModel,\n\t\t\tollamaOptions,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('ollamaApi');\n\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as ChatOllamaInput;\n\n\t\tconst model = new ChatOllama({\n\t\t\t...options,\n\t\t\tbaseUrl: credentials.baseUrl as string,\n\t\t\tmodel: modelName,\n\t\t\tformat: options.format === 'default' ? undefined : options.format,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,0BAMO;AAEP,0BAA6C;AAE7C,yBAA8D;AAC9D,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,aAAkC;AAAA,EAAxC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,mBAAmB,YAAY;AAAA,UACpC,mBAAmB,CAAC,2BAA2B;AAAA,QAChD;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,eAAe;AAAA,MAC7C,aAAa,CAAC,OAAO;AAAA,MACrB,GAAG;AAAA,MACH,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,SAAS,wCAAoB,OAAO,CAAC;AAAA,QACvF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,MAAM,KAAK,eAAe,WAAW;AAEzD,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,UAAU,KAAK,iBAAiB,WAAW,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/llms/LMChatOllama/LmChatOllama.node.ts"],"sourcesContent":["import type { ChatOllamaInput } from '@langchain/ollama';\nimport { ChatOllama } from '@langchain/ollama';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { ollamaModel, ollamaOptions, ollamaDescription } from '../LMOllama/description';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmChatOllama implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Ollama Chat Model',\n\n\t\tname: 'lmChatOllama',\n\t\ticon: 'file:ollama.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Language Model Ollama',\n\t\tdefaults: {\n\t\t\tname: 'Ollama Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatollama/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\t...ollamaDescription,\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\tollamaModel,\n\t\t\tollamaOptions,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('ollamaApi');\n\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as ChatOllamaInput;\n\t\tconst headers = credentials.apiKey\n\t\t\t? {\n\t\t\t\t\tAuthorization: `Bearer ${credentials.apiKey as string}`,\n\t\t\t\t}\n\t\t\t: undefined;\n\n\t\tconst model = new ChatOllama({\n\t\t\t...options,\n\t\t\tbaseUrl: credentials.baseUrl as string,\n\t\t\tmodel: modelName,\n\t\t\tformat: options.format === 'default' ? undefined : options.format,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t\theaders,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,0BAMO;AAEP,0BAA6C;AAE7C,yBAA8D;AAC9D,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,aAAkC;AAAA,EAAxC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,mBAAmB,YAAY;AAAA,UACpC,mBAAmB,CAAC,2BAA2B;AAAA,QAChD;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,eAAe;AAAA,MAC7C,aAAa,CAAC,OAAO;AAAA,MACrB,GAAG;AAAA,MACH,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,SAAS,wCAAoB,OAAO,CAAC;AAAA,QACvF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,MAAM,KAAK,eAAe,WAAW;AAEzD,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,UAAU,KAAK,iBAAiB,WAAW,WAAW,CAAC,CAAC;AAC9D,UAAM,UAAU,YAAY,SACzB;AAAA,MACA,eAAe,UAAU,YAAY,MAAgB;AAAA,IACtD,IACC;AAEH,UAAM,QAAQ,IAAI,yBAAW;AAAA,MAC5B,GAAG;AAAA,MACH,SAAS,YAAY;AAAA,MACrB,OAAO;AAAA,MACP,QAAQ,QAAQ,WAAW,YAAY,SAAY,QAAQ;AAAA,MAC3D,WAAW,CAAC,IAAI,mCAAc,IAAI,CAAC;AAAA,MACnC,qBAAiB,kEAA+B,IAAI;AAAA,MACpD;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
|
|
@@ -68,12 +68,16 @@ class LmOllama {
|
|
|
68
68
|
const credentials = await this.getCredentials("ollamaApi");
|
|
69
69
|
const modelName = this.getNodeParameter("model", itemIndex);
|
|
70
70
|
const options = this.getNodeParameter("options", itemIndex, {});
|
|
71
|
+
const headers = credentials.apiKey ? {
|
|
72
|
+
Authorization: `Bearer ${credentials.apiKey}`
|
|
73
|
+
} : void 0;
|
|
71
74
|
const model = new import_ollama.Ollama({
|
|
72
75
|
baseUrl: credentials.baseUrl,
|
|
73
76
|
model: modelName,
|
|
74
77
|
...options,
|
|
75
78
|
callbacks: [new import_N8nLlmTracing.N8nLlmTracing(this)],
|
|
76
|
-
onFailedAttempt: (0, import_n8nLlmFailedAttemptHandler.makeN8nLlmFailedAttemptHandler)(this)
|
|
79
|
+
onFailedAttempt: (0, import_n8nLlmFailedAttemptHandler.makeN8nLlmFailedAttemptHandler)(this),
|
|
80
|
+
headers
|
|
77
81
|
});
|
|
78
82
|
return {
|
|
79
83
|
response: model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/llms/LMOllama/LmOllama.node.ts"],"sourcesContent":["import { Ollama } from '@langchain/community/llms/ollama';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { ollamaDescription, ollamaModel, ollamaOptions } from './description';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmOllama implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Ollama Model',\n\n\t\tname: 'lmOllama',\n\t\ticon: 'file:ollama.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Language Model Ollama',\n\t\tdefaults: {\n\t\t\tname: 'Ollama Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Text Completion Models'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmollama/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\t...ollamaDescription,\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\tollamaModel,\n\t\t\tollamaOptions,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('ollamaApi');\n\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as object;\n\n\t\tconst model = new Ollama({\n\t\t\tbaseUrl: credentials.baseUrl as string,\n\t\t\tmodel: modelName,\n\t\t\t...options,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,0BAMO;AAEP,0BAA6C;AAE7C,yBAA8D;AAC9D,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,SAA8B;AAAA,EAApC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,mBAAmB,YAAY;AAAA,UACpC,mBAAmB,CAAC,wBAAwB;AAAA,QAC7C;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,eAAe;AAAA,MAC7C,aAAa,CAAC,OAAO;AAAA,MACrB,GAAG;AAAA,MACH,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,SAAS,wCAAoB,OAAO,CAAC;AAAA,QACvF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,MAAM,KAAK,eAAe,WAAW;AAEzD,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,UAAU,KAAK,iBAAiB,WAAW,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/llms/LMOllama/LmOllama.node.ts"],"sourcesContent":["import { Ollama } from '@langchain/community/llms/ollama';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { ollamaDescription, ollamaModel, ollamaOptions } from './description';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmOllama implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Ollama Model',\n\n\t\tname: 'lmOllama',\n\t\ticon: 'file:ollama.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Language Model Ollama',\n\t\tdefaults: {\n\t\t\tname: 'Ollama Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Text Completion Models'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmollama/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\t...ollamaDescription,\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\tollamaModel,\n\t\t\tollamaOptions,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('ollamaApi');\n\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as object;\n\t\tconst headers = credentials.apiKey\n\t\t\t? {\n\t\t\t\t\tAuthorization: `Bearer ${credentials.apiKey as string}`,\n\t\t\t\t}\n\t\t\t: undefined;\n\n\t\tconst model = new Ollama({\n\t\t\tbaseUrl: credentials.baseUrl as string,\n\t\t\tmodel: modelName,\n\t\t\t...options,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t\theaders,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,0BAMO;AAEP,0BAA6C;AAE7C,yBAA8D;AAC9D,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,SAA8B;AAAA,EAApC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,mBAAmB,YAAY;AAAA,UACpC,mBAAmB,CAAC,wBAAwB;AAAA,QAC7C;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,eAAe;AAAA,MAC7C,aAAa,CAAC,OAAO;AAAA,MACrB,GAAG;AAAA,MACH,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,SAAS,wCAAoB,OAAO,CAAC;AAAA,QACvF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,MAAM,KAAK,eAAe,WAAW;AAEzD,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,UAAU,KAAK,iBAAiB,WAAW,WAAW,CAAC,CAAC;AAC9D,UAAM,UAAU,YAAY,SACzB;AAAA,MACA,eAAe,UAAU,YAAY,MAAgB;AAAA,IACtD,IACC;AAEH,UAAM,QAAQ,IAAI,qBAAO;AAAA,MACxB,SAAS,YAAY;AAAA,MACrB,OAAO;AAAA,MACP,GAAG;AAAA,MACH,WAAW,CAAC,IAAI,mCAAc,IAAI,CAAC;AAAA,MACnC,qBAAiB,kEAA+B,IAAI;AAAA,MACpD;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.ts"],"sourcesContent":["import { HuggingFaceInference } from '@langchain/community/llms/hf';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmOpenHuggingFaceInference implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Hugging Face Inference Model',\n\n\t\tname: 'lmOpenHuggingFaceInference',\n\t\ticon: 'file:huggingface.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Language Model HuggingFaceInference',\n\t\tdefaults: {\n\t\t\tname: 'Hugging Face Inference Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Text Completion Models'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmopenhuggingfaceinference/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'huggingFaceApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.ts"],"sourcesContent":["import { HuggingFaceInference } from '@langchain/community/llms/hf';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmOpenHuggingFaceInference implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Hugging Face Inference Model',\n\n\t\tname: 'lmOpenHuggingFaceInference',\n\t\ticon: 'file:huggingface.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Language Model HuggingFaceInference',\n\t\tdefaults: {\n\t\t\tname: 'Hugging Face Inference Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Text Completion Models'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmopenhuggingfaceinference/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'huggingFaceApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'mistralai/Mistral-Nemo-Base-2407',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Custom Inference Endpoint',\n\t\t\t\t\t\tname: 'endpointUrl',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tdescription: 'Custom endpoint URL',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Frequency Penalty',\n\t\t\t\t\t\tname: 'frequencyPenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim\",\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokens',\n\t\t\t\t\t\tdefault: 128,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tmaxValue: 32768,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Presence Penalty',\n\t\t\t\t\t\tname: 'presencePenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics\",\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Top K',\n\t\t\t\t\t\tname: 'topK',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls the top tokens to consider within the sample operation to create new text',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Top P',\n\t\t\t\t\t\tname: 'topP',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('huggingFaceApi');\n\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as object;\n\n\t\t// LangChain does not yet support specifying Provider\n\t\t// That's why mistral's model is the default value\n\t\t// It is one of the few models that seem to work out of the box\n\t\t// Other models are returning \"Model x/y is not supported for task text-generation and provider z. Supported task: conversational.\"\n\t\t// https://github.com/langchain-ai/langchainjs/discussions/8434#discussioncomment-13603787\n\t\tconst model = new HuggingFaceInference({\n\t\t\tmodel: modelName,\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\t...options,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqC;AACrC,0BAMO;AAEP,0BAA6C;AAE7C,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,2BAAgD;AAAA,EAAtD;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,mBAAmB,YAAY;AAAA,UACpC,mBAAmB,CAAC,wBAAwB;AAAA,QAC7C;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,eAAe;AAAA,MAC7C,aAAa,CAAC,OAAO;AAAA,MACrB,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,SAAS,wCAAoB,OAAO,CAAC;AAAA,QACvF;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,aAAa;AAAA,UACb,aAAa;AAAA,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AACpF,UAAM,cAAc,MAAM,KAAK,eAAe,gBAAgB;AAE9D,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,UAAU,KAAK,iBAAiB,WAAW,WAAW,CAAC,CAAC;AAO9D,UAAM,QAAQ,IAAI,+BAAqB;AAAA,MACtC,OAAO;AAAA,MACP,QAAQ,YAAY;AAAA,MACpB,GAAG;AAAA,MACH,WAAW,CAAC,IAAI,mCAAc,IAAI,CAAC;AAAA,MACnC,qBAAiB,kEAA+B,IAAI;AAAA,IACrD,CAAC;AAED,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
|
|
@@ -83,6 +83,13 @@ class RerankerCohere {
|
|
|
83
83
|
value: "rerank-multilingual-v3.0"
|
|
84
84
|
}
|
|
85
85
|
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
displayName: "Top N",
|
|
89
|
+
name: "topN",
|
|
90
|
+
type: "number",
|
|
91
|
+
description: "The maximum number of documents to return after reranking",
|
|
92
|
+
default: 3
|
|
86
93
|
}
|
|
87
94
|
]
|
|
88
95
|
};
|
|
@@ -90,10 +97,12 @@ class RerankerCohere {
|
|
|
90
97
|
async supplyData(itemIndex) {
|
|
91
98
|
this.logger.debug("Supply data for reranking Cohere");
|
|
92
99
|
const modelName = this.getNodeParameter("modelName", itemIndex, "rerank-v3.5");
|
|
100
|
+
const topN = this.getNodeParameter("topN", itemIndex, 3);
|
|
93
101
|
const credentials = await this.getCredentials("cohereApi");
|
|
94
102
|
const reranker = new import_cohere.CohereRerank({
|
|
95
103
|
apiKey: credentials.apiKey,
|
|
96
|
-
model: modelName
|
|
104
|
+
model: modelName,
|
|
105
|
+
topN
|
|
97
106
|
});
|
|
98
107
|
return {
|
|
99
108
|
response: (0, import_logWrapper.logWrapper)(reranker, this)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/rerankers/RerankerCohere/RerankerCohere.node.ts"],"sourcesContent":["import { CohereRerank } from '@langchain/cohere';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\n\nexport class RerankerCohere implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Reranker Cohere',\n\t\tname: 'rerankerCohere',\n\t\ticon: { light: 'file:cohere.svg', dark: 'file:cohere.dark.svg' },\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription:\n\t\t\t'Use Cohere Reranker to reorder documents after retrieval from a vector store by relevance to the given query.',\n\t\tdefaults: {\n\t\t\tname: 'Reranker Cohere',\n\t\t},\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL: '={{ $credentials.host }}',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'cohereApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Rerankers'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.rerankercohere/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [NodeConnectionTypes.AiReranker],\n\t\toutputNames: ['Reranker'],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'modelName',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The model that should be used to rerank the documents. <a href=\"https://docs.cohere.com/docs/models\">Learn more</a>.',\n\t\t\t\tdefault: 'rerank-v3.5',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'rerank-v3.5',\n\t\t\t\t\t\tvalue: 'rerank-v3.5',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'rerank-english-v3.0',\n\t\t\t\t\t\tvalue: 'rerank-english-v3.0',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'rerank-multilingual-v3.0',\n\t\t\t\t\t\tvalue: 'rerank-multilingual-v3.0',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for reranking Cohere');\n\t\tconst modelName = this.getNodeParameter('modelName', itemIndex, 'rerank-v3.5') as string;\n\t\tconst credentials = await this.getCredentials<{ apiKey: string }>('cohereApi');\n\t\tconst reranker = new CohereRerank({\n\t\t\tapiKey: credentials.apiKey,\n\t\t\tmodel: modelName,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(reranker, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAC7B,0BAMO;AAEP,wBAA2B;AAEpB,MAAM,eAAoC;AAAA,EAA1C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM,EAAE,OAAO,mBAAmB,MAAM,uBAAuB;AAAA,MAC/D,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aACC;AAAA,MACD,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,iBAAiB;AAAA,QAChB,wBAAwB;AAAA,QACxB,SAAS;AAAA,MACV;AAAA,MACA,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,WAAW;AAAA,QACjB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,SAAS,CAAC,wCAAoB,UAAU;AAAA,MACxC,aAAa,CAAC,UAAU;AAAA,MACxB,YAAY;AAAA,QACX;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,aACC;AAAA,UACD,SAAS;AAAA,UACT,SAAS;AAAA,YACR;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,SAAK,OAAO,MAAM,kCAAkC;AACpD,UAAM,YAAY,KAAK,iBAAiB,aAAa,WAAW,aAAa;AAC7E,UAAM,cAAc,MAAM,KAAK,eAAmC,WAAW;
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/rerankers/RerankerCohere/RerankerCohere.node.ts"],"sourcesContent":["import { CohereRerank } from '@langchain/cohere';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\n\nexport class RerankerCohere implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Reranker Cohere',\n\t\tname: 'rerankerCohere',\n\t\ticon: { light: 'file:cohere.svg', dark: 'file:cohere.dark.svg' },\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription:\n\t\t\t'Use Cohere Reranker to reorder documents after retrieval from a vector store by relevance to the given query.',\n\t\tdefaults: {\n\t\t\tname: 'Reranker Cohere',\n\t\t},\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL: '={{ $credentials.host }}',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'cohereApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Rerankers'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.rerankercohere/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [NodeConnectionTypes.AiReranker],\n\t\toutputNames: ['Reranker'],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'modelName',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t'The model that should be used to rerank the documents. <a href=\"https://docs.cohere.com/docs/models\">Learn more</a>.',\n\t\t\t\tdefault: 'rerank-v3.5',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'rerank-v3.5',\n\t\t\t\t\t\tvalue: 'rerank-v3.5',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'rerank-english-v3.0',\n\t\t\t\t\t\tvalue: 'rerank-english-v3.0',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'rerank-multilingual-v3.0',\n\t\t\t\t\t\tvalue: 'rerank-multilingual-v3.0',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Top N',\n\t\t\t\tname: 'topN',\n\t\t\t\ttype: 'number',\n\t\t\t\tdescription: 'The maximum number of documents to return after reranking',\n\t\t\t\tdefault: 3,\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for reranking Cohere');\n\t\tconst modelName = this.getNodeParameter('modelName', itemIndex, 'rerank-v3.5') as string;\n\t\tconst topN = this.getNodeParameter('topN', itemIndex, 3) as number;\n\t\tconst credentials = await this.getCredentials<{ apiKey: string }>('cohereApi');\n\n\t\tconst reranker = new CohereRerank({\n\t\t\tapiKey: credentials.apiKey,\n\t\t\tmodel: modelName,\n\t\t\ttopN,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(reranker, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAC7B,0BAMO;AAEP,wBAA2B;AAEpB,MAAM,eAAoC;AAAA,EAA1C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM,EAAE,OAAO,mBAAmB,MAAM,uBAAuB;AAAA,MAC/D,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aACC;AAAA,MACD,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,iBAAiB;AAAA,QAChB,wBAAwB;AAAA,QACxB,SAAS;AAAA,MACV;AAAA,MACA,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,WAAW;AAAA,QACjB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,SAAS,CAAC,wCAAoB,UAAU;AAAA,MAC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