@n8n/n8n-nodes-langchain 1.114.0 → 1.115.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.
Files changed (46) hide show
  1. package/dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js +1 -1
  2. package/dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js.map +1 -1
  3. package/dist/known/credentials.json +1 -0
  4. package/dist/known/nodes.json +8 -0
  5. package/dist/nodes/vector_store/VectorStoreRedis/VectorStoreRedis.node.js +339 -0
  6. package/dist/nodes/vector_store/VectorStoreRedis/VectorStoreRedis.node.js.map +1 -0
  7. package/dist/nodes/vector_store/VectorStoreRedis/redis.dark.svg +37 -0
  8. package/dist/nodes/vector_store/VectorStoreRedis/redis.svg +37 -0
  9. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +15 -1
  10. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -1
  11. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js +3 -1
  12. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js.map +1 -1
  13. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.js +98 -0
  14. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.js.map +1 -0
  15. package/dist/nodes/vendors/Ollama/Ollama.node.js +42 -0
  16. package/dist/nodes/vendors/Ollama/Ollama.node.js.map +1 -0
  17. package/dist/nodes/vendors/Ollama/actions/descriptions.js +52 -0
  18. package/dist/nodes/vendors/Ollama/actions/descriptions.js.map +1 -0
  19. package/dist/nodes/vendors/Ollama/actions/image/analyze.operation.js +412 -0
  20. package/dist/nodes/vendors/Ollama/actions/image/analyze.operation.js.map +1 -0
  21. package/dist/nodes/vendors/Ollama/actions/image/index.js +64 -0
  22. package/dist/nodes/vendors/Ollama/actions/image/index.js.map +1 -0
  23. package/dist/nodes/vendors/Ollama/actions/node.type.js +17 -0
  24. package/dist/nodes/vendors/Ollama/actions/node.type.js.map +1 -0
  25. package/dist/nodes/vendors/Ollama/actions/router.js +78 -0
  26. package/dist/nodes/vendors/Ollama/actions/router.js.map +1 -0
  27. package/dist/nodes/vendors/Ollama/actions/text/index.js +64 -0
  28. package/dist/nodes/vendors/Ollama/actions/text/index.js.map +1 -0
  29. package/dist/nodes/vendors/Ollama/actions/text/message.operation.js +440 -0
  30. package/dist/nodes/vendors/Ollama/actions/text/message.operation.js.map +1 -0
  31. package/dist/nodes/vendors/Ollama/actions/versionDescription.js +107 -0
  32. package/dist/nodes/vendors/Ollama/actions/versionDescription.js.map +1 -0
  33. package/dist/nodes/vendors/Ollama/helpers/index.js +17 -0
  34. package/dist/nodes/vendors/Ollama/helpers/index.js.map +1 -0
  35. package/dist/nodes/vendors/Ollama/helpers/interfaces.js +17 -0
  36. package/dist/nodes/vendors/Ollama/helpers/interfaces.js.map +1 -0
  37. package/dist/nodes/vendors/Ollama/methods/index.js +39 -0
  38. package/dist/nodes/vendors/Ollama/methods/index.js.map +1 -0
  39. package/dist/nodes/vendors/Ollama/methods/listSearch.js +39 -0
  40. package/dist/nodes/vendors/Ollama/methods/listSearch.js.map +1 -0
  41. package/dist/nodes/vendors/Ollama/ollama.svg +1 -0
  42. package/dist/nodes/vendors/Ollama/transport/index.js +56 -0
  43. package/dist/nodes/vendors/Ollama/transport/index.js.map +1 -0
  44. package/dist/types/credentials.json +2 -2
  45. package/dist/types/nodes.json +2 -0
  46. package/package.json +11 -8
@@ -20,12 +20,14 @@ __reExport(operations_exports, require("./insertOperation"), module.exports);
20
20
  __reExport(operations_exports, require("./updateOperation"), module.exports);
21
21
  __reExport(operations_exports, require("./retrieveOperation"), module.exports);
22
22
  __reExport(operations_exports, require("./retrieveAsToolOperation"), module.exports);
23
+ __reExport(operations_exports, require("./retrieveAsToolExecuteOperation"), module.exports);
23
24
  // Annotate the CommonJS export names for ESM import in node:
24
25
  0 && (module.exports = {
25
26
  ...require("./loadOperation"),
26
27
  ...require("./insertOperation"),
27
28
  ...require("./updateOperation"),
28
29
  ...require("./retrieveOperation"),
29
- ...require("./retrieveAsToolOperation")
30
+ ...require("./retrieveAsToolOperation"),
31
+ ...require("./retrieveAsToolExecuteOperation")
30
32
  });
31
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/index.ts"],"sourcesContent":["export * from './loadOperation';\nexport * from './insertOperation';\nexport * from './updateOperation';\nexport * from './retrieveOperation';\nexport * from './retrieveAsToolOperation';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,4BAAd;AACA,+BAAc,8BADd;AAEA,+BAAc,8BAFd;AAGA,+BAAc,gCAHd;AAIA,+BAAc,sCAJd;","names":[]}
1
+ {"version":3,"sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/index.ts"],"sourcesContent":["export * from './loadOperation';\nexport * from './insertOperation';\nexport * from './updateOperation';\nexport * from './retrieveOperation';\nexport * from './retrieveAsToolOperation';\nexport * from './retrieveAsToolExecuteOperation';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,4BAAd;AACA,+BAAc,8BADd;AAEA,+BAAc,8BAFd;AAGA,+BAAc,gCAHd;AAIA,+BAAc,sCAJd;AAKA,+BAAc,6CALd;","names":[]}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var retrieveAsToolExecuteOperation_exports = {};
20
+ __export(retrieveAsToolExecuteOperation_exports, {
21
+ handleRetrieveAsToolExecuteOperation: () => handleRetrieveAsToolExecuteOperation
22
+ });
23
+ module.exports = __toCommonJS(retrieveAsToolExecuteOperation_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
25
+ var import_helpers = require("../../../../../utils/helpers");
26
+ async function handleRetrieveAsToolExecuteOperation(context, args, embeddings, itemIndex) {
27
+ const filter = (0, import_helpers.getMetadataFiltersValues)(context, itemIndex);
28
+ const vectorStore = await args.getVectorStoreClient(
29
+ context,
30
+ // We'll pass filter to similaritySearchVectorWithScore instead of getVectorStoreClient
31
+ void 0,
32
+ embeddings,
33
+ itemIndex
34
+ );
35
+ try {
36
+ const inputData = context.getInputData();
37
+ const item = inputData[itemIndex];
38
+ const query = typeof item.json.input === "string" ? item.json.input : void 0;
39
+ if (!query || typeof query !== "string") {
40
+ throw new Error('Input data must contain a "input" field with the search query');
41
+ }
42
+ const topK = context.getNodeParameter("topK", itemIndex, 4);
43
+ (0, import_n8n_workflow.assertParamIsNumber)("topK", topK, context.getNode());
44
+ const useReranker = context.getNodeParameter("useReranker", itemIndex, false);
45
+ (0, import_n8n_workflow.assertParamIsBoolean)("useReranker", useReranker, context.getNode());
46
+ const includeDocumentMetadata = context.getNodeParameter(
47
+ "includeDocumentMetadata",
48
+ itemIndex,
49
+ true
50
+ );
51
+ (0, import_n8n_workflow.assertParamIsBoolean)("includeDocumentMetadata", includeDocumentMetadata, context.getNode());
52
+ const embeddedQuery = await embeddings.embedQuery(query);
53
+ let docs = await vectorStore.similaritySearchVectorWithScore(embeddedQuery, topK, filter);
54
+ if (useReranker && docs.length > 0) {
55
+ const reranker = await context.getInputConnectionData(
56
+ import_n8n_workflow.NodeConnectionTypes.AiReranker,
57
+ 0
58
+ );
59
+ const documents = docs.map(([doc]) => doc);
60
+ const rerankedDocuments = await reranker.compressDocuments(documents, query);
61
+ docs = rerankedDocuments.map((doc) => {
62
+ const { relevanceScore, ...metadata } = doc.metadata || {};
63
+ return [{ ...doc, metadata }, relevanceScore ?? 0];
64
+ });
65
+ }
66
+ const serializedDocs = docs.map(([doc]) => {
67
+ if (includeDocumentMetadata) {
68
+ return {
69
+ type: "text",
70
+ text: JSON.stringify({ ...doc })
71
+ };
72
+ } else {
73
+ return {
74
+ type: "text",
75
+ pageContent: JSON.stringify({ pageContent: doc.pageContent })
76
+ };
77
+ }
78
+ });
79
+ (0, import_helpers.logAiEvent)(context, "ai-vector-store-searched", { input: query });
80
+ return [
81
+ {
82
+ json: {
83
+ response: serializedDocs
84
+ },
85
+ pairedItem: {
86
+ item: itemIndex
87
+ }
88
+ }
89
+ ];
90
+ } finally {
91
+ args.releaseVectorStoreClient?.(vectorStore);
92
+ }
93
+ }
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ handleRetrieveAsToolExecuteOperation
97
+ });
98
+ //# sourceMappingURL=retrieveAsToolExecuteOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolExecuteOperation.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { BaseDocumentCompressor } from '@langchain/core/retrievers/document_compressors';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport {\n\tassertParamIsBoolean,\n\tassertParamIsNumber,\n\tNodeConnectionTypes,\n\ttype IExecuteFunctions,\n\ttype INodeExecutionData,\n} from 'n8n-workflow';\n\nimport { getMetadataFiltersValues, logAiEvent } from '@utils/helpers';\n\nimport type { VectorStoreNodeConstructorArgs } from '../types';\n\n/**\n * Handles the 'retrieve-as-tool' operation mode in execute context\n * Searches the vector store for documents similar to a query and returns execution data\n * This is similar to the load operation but designed to work with the new tool execution pattern\n */\nexport async function handleRetrieveAsToolExecuteOperation<T extends VectorStore = VectorStore>(\n\tcontext: IExecuteFunctions,\n\targs: VectorStoreNodeConstructorArgs<T>,\n\tembeddings: Embeddings,\n\titemIndex: number,\n): Promise<INodeExecutionData[]> {\n\tconst filter = getMetadataFiltersValues(context, itemIndex);\n\tconst vectorStore = await args.getVectorStoreClient(\n\t\tcontext,\n\t\t// We'll pass filter to similaritySearchVectorWithScore instead of getVectorStoreClient\n\t\tundefined,\n\t\tembeddings,\n\t\titemIndex,\n\t);\n\n\ttry {\n\t\t// Get the search parameters - query from input data, others from node parameters\n\t\tconst inputData = context.getInputData();\n\t\tconst item = inputData[itemIndex];\n\t\tconst query = typeof item.json.input === 'string' ? item.json.input : undefined;\n\n\t\tif (!query || typeof query !== 'string') {\n\t\t\tthrow new Error('Input data must contain a \"input\" field with the search query');\n\t\t}\n\n\t\tconst topK = context.getNodeParameter('topK', itemIndex, 4);\n\t\tassertParamIsNumber('topK', topK, context.getNode());\n\t\tconst useReranker = context.getNodeParameter('useReranker', itemIndex, false);\n\t\tassertParamIsBoolean('useReranker', useReranker, context.getNode());\n\n\t\tconst includeDocumentMetadata = context.getNodeParameter(\n\t\t\t'includeDocumentMetadata',\n\t\t\titemIndex,\n\t\t\ttrue,\n\t\t);\n\t\tassertParamIsBoolean('includeDocumentMetadata', includeDocumentMetadata, context.getNode());\n\n\t\t// Embed the query to prepare for vector similarity search\n\t\tconst embeddedQuery = await embeddings.embedQuery(query);\n\n\t\t// Get the most similar documents to the embedded query\n\t\tlet docs = await vectorStore.similaritySearchVectorWithScore(embeddedQuery, topK, filter);\n\n\t\t// If reranker is used, rerank the documents\n\t\tif (useReranker && docs.length > 0) {\n\t\t\tconst reranker = (await context.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiReranker,\n\t\t\t\t0,\n\t\t\t)) as BaseDocumentCompressor;\n\t\t\tconst documents = docs.map(([doc]) => doc);\n\n\t\t\tconst rerankedDocuments = await reranker.compressDocuments(documents, query);\n\t\t\tdocs = rerankedDocuments.map((doc) => {\n\t\t\t\tconst { relevanceScore, ...metadata } = doc.metadata || {};\n\t\t\t\treturn [{ ...doc, metadata }, relevanceScore ?? 0];\n\t\t\t});\n\t\t}\n\n\t\t// Format the documents for the output similar to the original tool format\n\t\tconst serializedDocs = docs.map(([doc]) => {\n\t\t\tif (includeDocumentMetadata) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\ttext: JSON.stringify({ ...doc }),\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tpageContent: JSON.stringify({ pageContent: doc.pageContent }),\n\t\t\t\t};\n\t\t\t}\n\t\t});\n\n\t\t// Log the AI event for analytics\n\t\tlogAiEvent(context, 'ai-vector-store-searched', { input: query });\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tjson: {\n\t\t\t\t\tresponse: serializedDocs,\n\t\t\t\t},\n\t\t\t\tpairedItem: {\n\t\t\t\t\titem: itemIndex,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t} finally {\n\t\t// Release the vector store client if a release method was provided\n\t\targs.releaseVectorStoreClient?.(vectorStore);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAMO;AAEP,qBAAqD;AASrD,eAAsB,qCACrB,SACA,MACA,YACA,WACgC;AAChC,QAAM,aAAS,yCAAyB,SAAS,SAAS;AAC1D,QAAM,cAAc,MAAM,KAAK;AAAA,IAC9B;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,MAAI;AAEH,UAAM,YAAY,QAAQ,aAAa;AACvC,UAAM,OAAO,UAAU,SAAS;AAChC,UAAM,QAAQ,OAAO,KAAK,KAAK,UAAU,WAAW,KAAK,KAAK,QAAQ;AAEtE,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACxC,YAAM,IAAI,MAAM,+DAA+D;AAAA,IAChF;AAEA,UAAM,OAAO,QAAQ,iBAAiB,QAAQ,WAAW,CAAC;AAC1D,iDAAoB,QAAQ,MAAM,QAAQ,QAAQ,CAAC;AACnD,UAAM,cAAc,QAAQ,iBAAiB,eAAe,WAAW,KAAK;AAC5E,kDAAqB,eAAe,aAAa,QAAQ,QAAQ,CAAC;AAElE,UAAM,0BAA0B,QAAQ;AAAA,MACvC;AAAA,MACA;AAAA,MACA;AAAA,IACD;AACA,kDAAqB,2BAA2B,yBAAyB,QAAQ,QAAQ,CAAC;AAG1F,UAAM,gBAAgB,MAAM,WAAW,WAAW,KAAK;AAGvD,QAAI,OAAO,MAAM,YAAY,gCAAgC,eAAe,MAAM,MAAM;AAGxF,QAAI,eAAe,KAAK,SAAS,GAAG;AACnC,YAAM,WAAY,MAAM,QAAQ;AAAA,QAC/B,wCAAoB;AAAA,QACpB;AAAA,MACD;AACA,YAAM,YAAY,KAAK,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG;AAEzC,YAAM,oBAAoB,MAAM,SAAS,kBAAkB,WAAW,KAAK;AAC3E,aAAO,kBAAkB,IAAI,CAAC,QAAQ;AACrC,cAAM,EAAE,gBAAgB,GAAG,SAAS,IAAI,IAAI,YAAY,CAAC;AACzD,eAAO,CAAC,EAAE,GAAG,KAAK,SAAS,GAAG,kBAAkB,CAAC;AAAA,MAClD,CAAC;AAAA,IACF;AAGA,UAAM,iBAAiB,KAAK,IAAI,CAAC,CAAC,GAAG,MAAM;AAC1C,UAAI,yBAAyB;AAC5B,eAAO;AAAA,UACN,MAAM;AAAA,UACN,MAAM,KAAK,UAAU,EAAE,GAAG,IAAI,CAAC;AAAA,QAChC;AAAA,MACD,OAAO;AACN,eAAO;AAAA,UACN,MAAM;AAAA,UACN,aAAa,KAAK,UAAU,EAAE,aAAa,IAAI,YAAY,CAAC;AAAA,QAC7D;AAAA,MACD;AAAA,IACD,CAAC;AAGD,mCAAW,SAAS,4BAA4B,EAAE,OAAO,MAAM,CAAC;AAEhE,WAAO;AAAA,MACN;AAAA,QACC,MAAM;AAAA,UACL,UAAU;AAAA,QACX;AAAA,QACA,YAAY;AAAA,UACX,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,EACD,UAAE;AAED,SAAK,2BAA2B,WAAW;AAAA,EAC5C;AACD;","names":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Ollama_node_exports = {};
20
+ __export(Ollama_node_exports, {
21
+ Ollama: () => Ollama
22
+ });
23
+ module.exports = __toCommonJS(Ollama_node_exports);
24
+ var import_router = require("./actions/router");
25
+ var import_versionDescription = require("./actions/versionDescription");
26
+ var import_methods = require("./methods");
27
+ class Ollama {
28
+ constructor() {
29
+ this.description = import_versionDescription.versionDescription;
30
+ this.methods = {
31
+ listSearch: import_methods.listSearch
32
+ };
33
+ }
34
+ async execute() {
35
+ return await import_router.router.call(this);
36
+ }
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ Ollama
41
+ });
42
+ //# sourceMappingURL=Ollama.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../nodes/vendors/Ollama/Ollama.node.ts"],"sourcesContent":["import type { IExecuteFunctions, INodeType } from 'n8n-workflow';\n\nimport { router } from './actions/router';\nimport { versionDescription } from './actions/versionDescription';\nimport { listSearch } from './methods';\n\nexport class Ollama implements INodeType {\n\tdescription = versionDescription;\n\n\tmethods = {\n\t\tlistSearch,\n\t};\n\n\tasync execute(this: IExecuteFunctions) {\n\t\treturn await router.call(this);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAuB;AACvB,gCAAmC;AACnC,qBAA2B;AAEpB,MAAM,OAA4B;AAAA,EAAlC;AACN,uBAAc;AAEd,mBAAU;AAAA,MACT;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,UAAiC;AACtC,WAAO,MAAM,qBAAO,KAAK,IAAI;AAAA,EAC9B;AACD;","names":[]}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var descriptions_exports = {};
20
+ __export(descriptions_exports, {
21
+ modelRLC: () => modelRLC
22
+ });
23
+ module.exports = __toCommonJS(descriptions_exports);
24
+ const modelRLC = {
25
+ displayName: "Model",
26
+ name: "modelId",
27
+ type: "resourceLocator",
28
+ default: { mode: "list", value: "" },
29
+ required: true,
30
+ modes: [
31
+ {
32
+ displayName: "From List",
33
+ name: "list",
34
+ type: "list",
35
+ typeOptions: {
36
+ searchListMethod: "modelSearch",
37
+ searchable: true
38
+ }
39
+ },
40
+ {
41
+ displayName: "ID",
42
+ name: "id",
43
+ type: "string",
44
+ placeholder: "e.g. llava, llama3.2-vision"
45
+ }
46
+ ]
47
+ };
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ modelRLC
51
+ });
52
+ //# sourceMappingURL=descriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../nodes/vendors/Ollama/actions/descriptions.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nexport const modelRLC: INodeProperties = {\n\tdisplayName: 'Model',\n\tname: 'modelId',\n\ttype: 'resourceLocator',\n\tdefault: { mode: 'list', value: '' },\n\trequired: true,\n\tmodes: [\n\t\t{\n\t\t\tdisplayName: 'From List',\n\t\t\tname: 'list',\n\t\t\ttype: 'list',\n\t\t\ttypeOptions: {\n\t\t\t\tsearchListMethod: 'modelSearch',\n\t\t\t\tsearchable: true,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'ID',\n\t\t\tname: 'id',\n\t\t\ttype: 'string',\n\t\t\tplaceholder: 'e.g. llava, llama3.2-vision',\n\t\t},\n\t],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,WAA4B;AAAA,EACxC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS,EAAE,MAAM,QAAQ,OAAO,GAAG;AAAA,EACnC,UAAU;AAAA,EACV,OAAO;AAAA,IACN;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,QACZ,kBAAkB;AAAA,QAClB,YAAY;AAAA,MACb;AAAA,IACD;AAAA,IACA;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACd;AAAA,EACD;AACD;","names":[]}
@@ -0,0 +1,412 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var analyze_operation_exports = {};
20
+ __export(analyze_operation_exports, {
21
+ description: () => description,
22
+ execute: () => execute
23
+ });
24
+ module.exports = __toCommonJS(analyze_operation_exports);
25
+ var import_n8n_workflow = require("n8n-workflow");
26
+ var import_transport = require("../../transport");
27
+ var import_descriptions = require("../descriptions");
28
+ const properties = [
29
+ import_descriptions.modelRLC,
30
+ {
31
+ displayName: "Text Input",
32
+ name: "text",
33
+ type: "string",
34
+ placeholder: "e.g. What's in this image?",
35
+ default: "What's in this image?",
36
+ typeOptions: {
37
+ rows: 2
38
+ }
39
+ },
40
+ {
41
+ displayName: "Input Type",
42
+ name: "inputType",
43
+ type: "options",
44
+ default: "binary",
45
+ options: [
46
+ {
47
+ name: "Binary File(s)",
48
+ value: "binary"
49
+ },
50
+ {
51
+ name: "Image URL(s)",
52
+ value: "url"
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ displayName: "Input Data Field Name(s)",
58
+ name: "binaryPropertyName",
59
+ type: "string",
60
+ default: "data",
61
+ placeholder: "e.g. data",
62
+ hint: "The name of the input field containing the binary file data to be processed",
63
+ description: "Name of the binary field(s) which contains the image(s), separate multiple field names with commas",
64
+ displayOptions: {
65
+ show: {
66
+ inputType: ["binary"]
67
+ }
68
+ }
69
+ },
70
+ {
71
+ displayName: "URL(s)",
72
+ name: "imageUrls",
73
+ type: "string",
74
+ placeholder: "e.g. https://example.com/image.png",
75
+ description: "URL(s) of the image(s) to analyze, multiple URLs can be added separated by comma",
76
+ default: "",
77
+ displayOptions: {
78
+ show: {
79
+ inputType: ["url"]
80
+ }
81
+ }
82
+ },
83
+ {
84
+ displayName: "Simplify Output",
85
+ name: "simplify",
86
+ type: "boolean",
87
+ default: true,
88
+ description: "Whether to simplify the response or not"
89
+ },
90
+ {
91
+ displayName: "Options",
92
+ name: "options",
93
+ placeholder: "Add Option",
94
+ type: "collection",
95
+ default: {},
96
+ options: [
97
+ {
98
+ displayName: "System Message",
99
+ name: "system",
100
+ type: "string",
101
+ default: "",
102
+ placeholder: "e.g. You are a helpful assistant.",
103
+ description: "System message to set the context for the conversation",
104
+ typeOptions: {
105
+ rows: 2
106
+ }
107
+ },
108
+ {
109
+ displayName: "Temperature",
110
+ name: "temperature",
111
+ type: "number",
112
+ default: 0.8,
113
+ typeOptions: {
114
+ minValue: 0,
115
+ maxValue: 2,
116
+ numberPrecision: 2
117
+ },
118
+ description: "Controls randomness in responses. Lower values make output more focused."
119
+ },
120
+ {
121
+ displayName: "Output Randomness (Top P)",
122
+ name: "top_p",
123
+ default: 0.7,
124
+ description: "The maximum cumulative probability of tokens to consider when sampling",
125
+ type: "number",
126
+ typeOptions: {
127
+ minValue: 0,
128
+ maxValue: 1,
129
+ numberPrecision: 1
130
+ }
131
+ },
132
+ {
133
+ displayName: "Top K",
134
+ name: "top_k",
135
+ type: "number",
136
+ default: 40,
137
+ typeOptions: {
138
+ minValue: 1
139
+ },
140
+ description: "Controls diversity by limiting the number of top tokens to consider"
141
+ },
142
+ {
143
+ displayName: "Max Tokens",
144
+ name: "num_predict",
145
+ type: "number",
146
+ default: 1024,
147
+ typeOptions: {
148
+ minValue: 1,
149
+ numberPrecision: 0
150
+ },
151
+ description: "Maximum number of tokens to generate in the completion"
152
+ },
153
+ {
154
+ displayName: "Frequency Penalty",
155
+ name: "frequency_penalty",
156
+ type: "number",
157
+ default: 0,
158
+ typeOptions: {
159
+ minValue: 0,
160
+ numberPrecision: 2
161
+ },
162
+ description: "Adjusts the penalty for tokens that have already appeared in the generated text. Higher values discourage repetition."
163
+ },
164
+ {
165
+ displayName: "Presence Penalty",
166
+ name: "presence_penalty",
167
+ type: "number",
168
+ default: 0,
169
+ typeOptions: {
170
+ numberPrecision: 2
171
+ },
172
+ description: "Adjusts the penalty for tokens based on their presence in the generated text so far. Positive values penalize tokens that have already appeared, encouraging diversity."
173
+ },
174
+ {
175
+ displayName: "Repetition Penalty",
176
+ name: "repeat_penalty",
177
+ type: "number",
178
+ default: 1.1,
179
+ typeOptions: {
180
+ minValue: 0,
181
+ numberPrecision: 2
182
+ },
183
+ description: "Sets how strongly to penalize repetitions. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient."
184
+ },
185
+ {
186
+ displayName: "Context Length",
187
+ name: "num_ctx",
188
+ type: "number",
189
+ default: 4096,
190
+ typeOptions: {
191
+ minValue: 1,
192
+ numberPrecision: 0
193
+ },
194
+ description: "Sets the size of the context window used to generate the next token"
195
+ },
196
+ {
197
+ displayName: "Repeat Last N",
198
+ name: "repeat_last_n",
199
+ type: "number",
200
+ default: 64,
201
+ typeOptions: {
202
+ minValue: -1,
203
+ numberPrecision: 0
204
+ },
205
+ description: "Sets how far back for the model to look back to prevent repetition. (0 = disabled, -1 = num_ctx)."
206
+ },
207
+ {
208
+ displayName: "Min P",
209
+ name: "min_p",
210
+ type: "number",
211
+ default: 0,
212
+ typeOptions: {
213
+ minValue: 0,
214
+ maxValue: 1,
215
+ numberPrecision: 3
216
+ },
217
+ description: "Alternative to the top_p, and aims to ensure a balance of quality and variety. The parameter p represents the minimum probability for a token to be considered, relative to the probability of the most likely token."
218
+ },
219
+ {
220
+ displayName: "Seed",
221
+ name: "seed",
222
+ type: "number",
223
+ default: 0,
224
+ typeOptions: {
225
+ minValue: 0,
226
+ numberPrecision: 0
227
+ },
228
+ description: "Sets the random number seed to use for generation. Setting this to a specific number will make the model generate the same text for the same prompt."
229
+ },
230
+ {
231
+ displayName: "Stop Sequences",
232
+ name: "stop",
233
+ type: "string",
234
+ default: "",
235
+ description: "Sets the stop sequences to use. When this pattern is encountered the LLM will stop generating text and return. Separate multiple patterns with commas"
236
+ },
237
+ {
238
+ displayName: "Keep Alive",
239
+ name: "keep_alive",
240
+ type: "string",
241
+ default: "5m",
242
+ description: "Specifies the duration to keep the loaded model in memory after use. Format: 1h30m (1 hour 30 minutes)."
243
+ },
244
+ {
245
+ displayName: "Low VRAM Mode",
246
+ name: "low_vram",
247
+ type: "boolean",
248
+ default: false,
249
+ description: "Whether to activate low VRAM mode, which reduces memory usage at the cost of slower generation speed. Useful for GPUs with limited memory."
250
+ },
251
+ {
252
+ displayName: "Main GPU ID",
253
+ name: "main_gpu",
254
+ type: "number",
255
+ default: 0,
256
+ typeOptions: {
257
+ minValue: 0,
258
+ numberPrecision: 0
259
+ },
260
+ description: "Specifies the ID of the GPU to use for the main computation. Only change this if you have multiple GPUs."
261
+ },
262
+ {
263
+ displayName: "Context Batch Size",
264
+ name: "num_batch",
265
+ type: "number",
266
+ default: 512,
267
+ typeOptions: {
268
+ minValue: 1,
269
+ numberPrecision: 0
270
+ },
271
+ description: "Sets the batch size for prompt processing. Larger batch sizes may improve generation speed but increase memory usage."
272
+ },
273
+ {
274
+ displayName: "Number of GPUs",
275
+ name: "num_gpu",
276
+ type: "number",
277
+ default: -1,
278
+ typeOptions: {
279
+ minValue: -1,
280
+ numberPrecision: 0
281
+ },
282
+ description: "Specifies the number of GPUs to use for parallel processing. Set to -1 for auto-detection."
283
+ },
284
+ {
285
+ displayName: "Number of CPU Threads",
286
+ name: "num_thread",
287
+ type: "number",
288
+ default: 0,
289
+ typeOptions: {
290
+ minValue: 0,
291
+ numberPrecision: 0
292
+ },
293
+ description: "Specifies the number of CPU threads to use for processing. Set to 0 for auto-detection."
294
+ },
295
+ {
296
+ displayName: "Penalize Newlines",
297
+ name: "penalize_newline",
298
+ type: "boolean",
299
+ default: true,
300
+ description: "Whether the model will be less likely to generate newline characters, encouraging longer continuous sequences of text"
301
+ },
302
+ {
303
+ displayName: "Use Memory Locking",
304
+ name: "use_mlock",
305
+ type: "boolean",
306
+ default: false,
307
+ description: "Whether to lock the model in memory to prevent swapping. This can improve performance but requires sufficient available memory."
308
+ },
309
+ {
310
+ displayName: "Use Memory Mapping",
311
+ name: "use_mmap",
312
+ type: "boolean",
313
+ default: true,
314
+ description: "Whether to use memory mapping for loading the model. This can reduce memory usage but may impact performance."
315
+ },
316
+ {
317
+ displayName: "Load Vocabulary Only",
318
+ name: "vocab_only",
319
+ type: "boolean",
320
+ default: false,
321
+ description: "Whether to only load the model vocabulary without the weights. Useful for quickly testing tokenization."
322
+ },
323
+ {
324
+ displayName: "Output Format",
325
+ name: "format",
326
+ type: "options",
327
+ options: [
328
+ { name: "Default", value: "" },
329
+ { name: "JSON", value: "json" }
330
+ ],
331
+ default: "",
332
+ description: "Specifies the format of the API response"
333
+ }
334
+ ]
335
+ }
336
+ ];
337
+ const displayOptions = {
338
+ show: {
339
+ operation: ["analyze"],
340
+ resource: ["image"]
341
+ }
342
+ };
343
+ const description = (0, import_n8n_workflow.updateDisplayOptions)(displayOptions, properties);
344
+ async function execute(i) {
345
+ const model = this.getNodeParameter("modelId", i, "", { extractValue: true });
346
+ const inputType = this.getNodeParameter("inputType", i, "binary");
347
+ const text = this.getNodeParameter("text", i, "");
348
+ const simplify = this.getNodeParameter("simplify", i, true);
349
+ const options = this.getNodeParameter("options", i, {});
350
+ let images;
351
+ if (inputType === "url") {
352
+ const urls = this.getNodeParameter("imageUrls", i, "");
353
+ const urlList = urls.split(",").map((url) => url.trim()).filter((url) => url);
354
+ const imagePromises = urlList.map(async (url) => {
355
+ const response2 = await this.helpers.httpRequest({
356
+ method: "GET",
357
+ url,
358
+ encoding: "arraybuffer"
359
+ });
360
+ return response2.toString("base64");
361
+ });
362
+ images = await Promise.all(imagePromises);
363
+ } else {
364
+ const binaryPropertyNames = this.getNodeParameter("binaryPropertyName", i, "data");
365
+ const propertyNames = binaryPropertyNames.split(",").map((name) => name.trim()).filter((name) => name);
366
+ const imagePromises = propertyNames.map(async (binaryPropertyName) => {
367
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
368
+ return buffer.toString("base64");
369
+ });
370
+ images = await Promise.all(imagePromises);
371
+ }
372
+ const messages = [
373
+ {
374
+ role: "user",
375
+ content: text,
376
+ images
377
+ }
378
+ ];
379
+ const processedOptions = { ...options };
380
+ if (processedOptions.stop && typeof processedOptions.stop === "string") {
381
+ processedOptions.stop = processedOptions.stop.split(",").map((s) => s.trim()).filter(Boolean);
382
+ }
383
+ const body = {
384
+ model,
385
+ messages,
386
+ stream: false,
387
+ options: processedOptions
388
+ };
389
+ const response = await import_transport.apiRequest.call(this, "POST", "/api/chat", {
390
+ body
391
+ });
392
+ if (simplify) {
393
+ return [
394
+ {
395
+ json: { content: response.message.content },
396
+ pairedItem: { item: i }
397
+ }
398
+ ];
399
+ }
400
+ return [
401
+ {
402
+ json: { ...response },
403
+ pairedItem: { item: i }
404
+ }
405
+ ];
406
+ }
407
+ // Annotate the CommonJS export names for ESM import in node:
408
+ 0 && (module.exports = {
409
+ description,
410
+ execute
411
+ });
412
+ //# sourceMappingURL=analyze.operation.js.map