n8n-nodes-ollama-reranker 1.2.0 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import { ISupplyDataFunctions, SupplyData, INodeType, INodeTypeDescription } from 'n8n-workflow';
1
+ import { ILoadOptionsFunctions, INodePropertyOptions, ISupplyDataFunctions, SupplyData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
2
  /**
3
3
  * Ollama Reranker Provider
4
4
  *
@@ -12,6 +12,15 @@ import { ISupplyDataFunctions, SupplyData, INodeType, INodeTypeDescription } fro
12
12
  */
13
13
  export declare class OllamaReranker implements INodeType {
14
14
  description: INodeTypeDescription;
15
+ methods: {
16
+ loadOptions: {
17
+ /**
18
+ * Load models from Ollama/Custom Rerank API
19
+ * Dynamically fetches available models from /api/tags endpoint
20
+ */
21
+ getModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
22
+ };
23
+ };
15
24
  /**
16
25
  * Supply Data Method (NOT execute!)
17
26
  *
@@ -56,48 +56,11 @@ class OllamaReranker {
56
56
  displayName: 'Model',
57
57
  name: 'model',
58
58
  type: 'options',
59
- options: [
60
- {
61
- name: 'BGE Reranker v2-M3 (Recommended)',
62
- value: 'bge-reranker-v2-m3',
63
- description: 'Best general-purpose reranker, excellent balance of speed and accuracy',
64
- },
65
- {
66
- name: 'Qwen3-Reranker-0.6B (Fast)',
67
- value: 'dengcao/Qwen3-Reranker-0.6B:Q5_K_M',
68
- description: 'Fastest option, best for resource-limited environments',
69
- },
70
- {
71
- name: 'Qwen3-Reranker-4B (Balanced)',
72
- value: 'dengcao/Qwen3-Reranker-4B:Q5_K_M',
73
- description: 'Recommended for Qwen family - best balance of speed and accuracy',
74
- },
75
- {
76
- name: 'Qwen3-Reranker-8B (Most Accurate)',
77
- value: 'dengcao/Qwen3-Reranker-8B:Q5_K_M',
78
- description: 'Highest accuracy, requires more resources',
79
- },
80
- {
81
- name: 'Custom Model',
82
- value: 'custom',
83
- description: 'Specify your own Ollama reranker model',
84
- },
85
- ],
86
- default: 'bge-reranker-v2-m3',
87
- description: 'The Ollama reranker model to use',
88
- },
89
- {
90
- displayName: 'Custom Model Name',
91
- name: 'customModel',
92
- type: 'string',
93
- default: '',
94
- placeholder: 'your-reranker-model:tag',
95
- description: 'Name of your custom Ollama reranker model',
96
- displayOptions: {
97
- show: {
98
- model: ['custom'],
99
- },
59
+ typeOptions: {
60
+ loadOptionsMethod: 'getModels',
100
61
  },
62
+ default: '',
63
+ description: 'The reranker model to use - models are loaded from your configured Ollama/Custom API',
101
64
  },
102
65
  {
103
66
  displayName: 'API Type',
@@ -188,6 +151,47 @@ class OllamaReranker {
188
151
  },
189
152
  ],
190
153
  };
154
+ this.methods = {
155
+ loadOptions: {
156
+ /**
157
+ * Load models from Ollama/Custom Rerank API
158
+ * Dynamically fetches available models from /api/tags endpoint
159
+ */
160
+ async getModels() {
161
+ const credentials = await this.getCredentials('ollamaApi');
162
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.host)) {
163
+ return [];
164
+ }
165
+ const baseUrl = credentials.host.replace(/\/$/, '');
166
+ try {
167
+ const response = await this.helpers.httpRequest({
168
+ method: 'GET',
169
+ url: `${baseUrl}/api/tags`,
170
+ json: true,
171
+ timeout: 5000,
172
+ });
173
+ if (!(response === null || response === void 0 ? void 0 : response.models) || !Array.isArray(response.models)) {
174
+ return [];
175
+ }
176
+ // Sort models alphabetically
177
+ const models = response.models.sort((a, b) => {
178
+ const nameA = a.name || '';
179
+ const nameB = b.name || '';
180
+ return nameA.localeCompare(nameB);
181
+ });
182
+ return models.map((model) => ({
183
+ name: model.name,
184
+ value: model.name,
185
+ description: model.details || `Size: ${Math.round((model.size || 0) / 1024 / 1024)}MB`,
186
+ }));
187
+ }
188
+ catch (error) {
189
+ // If API call fails, return empty array (user can still type model name manually)
190
+ return [];
191
+ }
192
+ },
193
+ },
194
+ };
191
195
  }
192
196
  /**
193
197
  * Supply Data Method (NOT execute!)
@@ -200,12 +204,9 @@ class OllamaReranker {
200
204
  this.logger.debug('Initializing Ollama Reranker Provider');
201
205
  const self = this;
202
206
  // Get node parameters once (provider nodes use index 0)
203
- let model = this.getNodeParameter('model', 0);
204
- if (model === 'custom') {
205
- model = this.getNodeParameter('customModel', 0);
206
- if (!(model === null || model === void 0 ? void 0 : model.trim())) {
207
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Custom model name is required when "Custom Model" is selected');
208
- }
207
+ const model = this.getNodeParameter('model', 0);
208
+ if (!(model === null || model === void 0 ? void 0 : model.trim())) {
209
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Model selection is required. Please select a model from the dropdown.');
209
210
  }
210
211
  const apiType = this.getNodeParameter('apiType', 0, 'ollama');
211
212
  const instruction = this.getNodeParameter('instruction', 0);
@@ -1,4 +1,4 @@
1
- import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
1
+ import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
2
  /**
3
3
  * Ollama Reranker Workflow Node
4
4
  *
@@ -13,6 +13,15 @@ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription
13
13
  */
14
14
  export declare class OllamaRerankerWorkflow implements INodeType {
15
15
  description: INodeTypeDescription;
16
+ methods: {
17
+ loadOptions: {
18
+ /**
19
+ * Load models from Ollama/Custom Rerank API
20
+ * Dynamically fetches available models from /api/tags endpoint
21
+ */
22
+ getModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
23
+ };
24
+ };
16
25
  /**
17
26
  * Execute Method (NOT supplyData!)
18
27
  *
@@ -53,53 +53,16 @@ class OllamaRerankerWorkflow {
53
53
  },
54
54
  ],
55
55
  properties: [
56
- // Model selection (same as provider node)
56
+ // Model selection with dynamic loading
57
57
  {
58
58
  displayName: 'Model',
59
59
  name: 'model',
60
60
  type: 'options',
61
- options: [
62
- {
63
- name: 'BGE Reranker v2-M3 (Recommended)',
64
- value: 'bge-reranker-v2-m3',
65
- description: 'Best general-purpose reranker',
66
- },
67
- {
68
- name: 'Qwen3-Reranker-0.6B (Fast)',
69
- value: 'dengcao/Qwen3-Reranker-0.6B:Q5_K_M',
70
- description: 'Fastest option',
71
- },
72
- {
73
- name: 'Qwen3-Reranker-4B (Balanced)',
74
- value: 'dengcao/Qwen3-Reranker-4B:Q5_K_M',
75
- description: 'Best balance',
76
- },
77
- {
78
- name: 'Qwen3-Reranker-8B (Most Accurate)',
79
- value: 'dengcao/Qwen3-Reranker-8B:Q5_K_M',
80
- description: 'Highest accuracy',
81
- },
82
- {
83
- name: 'Custom Model',
84
- value: 'custom',
85
- description: 'Specify your own model',
86
- },
87
- ],
88
- default: 'bge-reranker-v2-m3',
89
- description: 'Ollama reranker model to use',
90
- },
91
- {
92
- displayName: 'Custom Model Name',
93
- name: 'customModel',
94
- type: 'string',
95
- default: '',
96
- placeholder: 'your-reranker-model:tag',
97
- description: 'Name of your custom Ollama reranker model',
98
- displayOptions: {
99
- show: {
100
- model: ['custom'],
101
- },
61
+ typeOptions: {
62
+ loadOptionsMethod: 'getModels',
102
63
  },
64
+ default: '',
65
+ description: 'The reranker model to use - models are loaded from your configured Ollama/Custom API',
103
66
  },
104
67
  // API Type selection
105
68
  {
@@ -289,6 +252,47 @@ class OllamaRerankerWorkflow {
289
252
  },
290
253
  ],
291
254
  };
255
+ this.methods = {
256
+ loadOptions: {
257
+ /**
258
+ * Load models from Ollama/Custom Rerank API
259
+ * Dynamically fetches available models from /api/tags endpoint
260
+ */
261
+ async getModels() {
262
+ const credentials = await this.getCredentials('ollamaApi');
263
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.host)) {
264
+ return [];
265
+ }
266
+ const baseUrl = credentials.host.replace(/\/$/, '');
267
+ try {
268
+ const response = await this.helpers.httpRequest({
269
+ method: 'GET',
270
+ url: `${baseUrl}/api/tags`,
271
+ json: true,
272
+ timeout: 5000,
273
+ });
274
+ if (!(response === null || response === void 0 ? void 0 : response.models) || !Array.isArray(response.models)) {
275
+ return [];
276
+ }
277
+ // Sort models alphabetically
278
+ const models = response.models.sort((a, b) => {
279
+ const nameA = a.name || '';
280
+ const nameB = b.name || '';
281
+ return nameA.localeCompare(nameB);
282
+ });
283
+ return models.map((model) => ({
284
+ name: model.name,
285
+ value: model.name,
286
+ description: model.details || `Size: ${Math.round((model.size || 0) / 1024 / 1024)}MB`,
287
+ }));
288
+ }
289
+ catch (error) {
290
+ // If API call fails, return empty array (user can still type model name manually)
291
+ return [];
292
+ }
293
+ },
294
+ },
295
+ };
292
296
  }
293
297
  /**
294
298
  * Execute Method (NOT supplyData!)
@@ -307,12 +311,9 @@ class OllamaRerankerWorkflow {
307
311
  }
308
312
  const ollamaHost = credentials.host.replace(/\/$/, '');
309
313
  // Get model
310
- let model = this.getNodeParameter('model', 0);
311
- if (model === 'custom') {
312
- model = this.getNodeParameter('customModel', 0);
313
- if (!(model === null || model === void 0 ? void 0 : model.trim())) {
314
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Custom model name is required');
315
- }
314
+ const model = this.getNodeParameter('model', 0);
315
+ if (!(model === null || model === void 0 ? void 0 : model.trim())) {
316
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Model selection is required. Please select a model from the dropdown.');
316
317
  }
317
318
  // Get API type
318
319
  const apiType = this.getNodeParameter('apiType', 0, 'ollama');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "n8n-nodes-ollama-reranker",
3
- "version": "1.2.0",
4
- "description": "Ollama Reranker for n8n - Supports Ollama Generate API + Custom Rerank API (Vector Store provider + chainable workflow node)",
3
+ "version": "1.3.0",
4
+ "description": "Ollama Reranker for n8n - Dynamic model loading + Ollama/Custom API support (Vector Store provider + workflow node)",
5
5
  "main": "index.js",
6
6
  "author": "Gabriel BRUMENT",
7
7
  "license": "MIT",