n8n-nodes-ollama-reranker 1.3.0 → 1.3.2
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/nodes/OllamaReranker/OllamaReranker.node.d.ts +1 -10
- package/dist/nodes/OllamaReranker/OllamaReranker.node.js +41 -47
- package/dist/nodes/OllamaRerankerWorkflow/OllamaRerankerWorkflow.node.d.ts +1 -10
- package/dist/nodes/OllamaRerankerWorkflow/OllamaRerankerWorkflow.node.js +42 -48
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ISupplyDataFunctions, SupplyData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
/**
|
|
3
3
|
* Ollama Reranker Provider
|
|
4
4
|
*
|
|
@@ -12,15 +12,6 @@ import { ILoadOptionsFunctions, INodePropertyOptions, ISupplyDataFunctions, Supp
|
|
|
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
|
-
};
|
|
24
15
|
/**
|
|
25
16
|
* Supply Data Method (NOT execute!)
|
|
26
17
|
*
|
|
@@ -51,16 +51,51 @@ class OllamaReranker {
|
|
|
51
51
|
required: true,
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
|
+
requestDefaults: {
|
|
55
|
+
ignoreHttpStatusErrors: true,
|
|
56
|
+
baseURL: '={{ $credentials.baseUrl.replace(new RegExp("/$"), "") }}',
|
|
57
|
+
},
|
|
54
58
|
properties: [
|
|
55
59
|
{
|
|
56
60
|
displayName: 'Model',
|
|
57
61
|
name: 'model',
|
|
58
62
|
type: 'options',
|
|
59
|
-
typeOptions: {
|
|
60
|
-
loadOptionsMethod: 'getModels',
|
|
61
|
-
},
|
|
62
63
|
default: '',
|
|
63
64
|
description: 'The reranker model to use - models are loaded from your configured Ollama/Custom API',
|
|
65
|
+
typeOptions: {
|
|
66
|
+
loadOptions: {
|
|
67
|
+
routing: {
|
|
68
|
+
request: {
|
|
69
|
+
method: 'GET',
|
|
70
|
+
url: '/api/tags',
|
|
71
|
+
},
|
|
72
|
+
output: {
|
|
73
|
+
postReceive: [
|
|
74
|
+
{
|
|
75
|
+
type: 'rootProperty',
|
|
76
|
+
properties: {
|
|
77
|
+
property: 'models',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'setKeyValue',
|
|
82
|
+
properties: {
|
|
83
|
+
name: '={{$responseItem.name}}',
|
|
84
|
+
value: '={{$responseItem.name}}',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'sort',
|
|
89
|
+
properties: {
|
|
90
|
+
key: 'name',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
required: true,
|
|
64
99
|
},
|
|
65
100
|
{
|
|
66
101
|
displayName: 'API Type',
|
|
@@ -151,47 +186,6 @@ class OllamaReranker {
|
|
|
151
186
|
},
|
|
152
187
|
],
|
|
153
188
|
};
|
|
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
|
-
};
|
|
195
189
|
}
|
|
196
190
|
/**
|
|
197
191
|
* Supply Data Method (NOT execute!)
|
|
@@ -216,10 +210,10 @@ class OllamaReranker {
|
|
|
216
210
|
const includeOriginalScores = (_c = additionalOptions.includeOriginalScores) !== null && _c !== void 0 ? _c : false;
|
|
217
211
|
// Get credentials (n8n's built-in ollamaApi)
|
|
218
212
|
const credentials = await this.getCredentials('ollamaApi');
|
|
219
|
-
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.
|
|
220
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Ollama
|
|
213
|
+
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.baseUrl)) {
|
|
214
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Ollama Base URL not configured. Please add Ollama API credentials with a valid Base URL.');
|
|
221
215
|
}
|
|
222
|
-
const ollamaHost = credentials.
|
|
216
|
+
const ollamaHost = credentials.baseUrl.replace(/\/$/, '');
|
|
223
217
|
/**
|
|
224
218
|
* Reranker Provider Object
|
|
225
219
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IExecuteFunctions,
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
/**
|
|
3
3
|
* Ollama Reranker Workflow Node
|
|
4
4
|
*
|
|
@@ -13,15 +13,6 @@ import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodeProp
|
|
|
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
|
-
};
|
|
25
16
|
/**
|
|
26
17
|
* Execute Method (NOT supplyData!)
|
|
27
18
|
*
|
|
@@ -52,17 +52,52 @@ class OllamaRerankerWorkflow {
|
|
|
52
52
|
required: true,
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
|
+
requestDefaults: {
|
|
56
|
+
ignoreHttpStatusErrors: true,
|
|
57
|
+
baseURL: '={{ $credentials.baseUrl.replace(new RegExp("/$"), "") }}',
|
|
58
|
+
},
|
|
55
59
|
properties: [
|
|
56
|
-
// Model selection with dynamic loading
|
|
60
|
+
// Model selection with dynamic loading (using routing like Ollama Chat Model)
|
|
57
61
|
{
|
|
58
62
|
displayName: 'Model',
|
|
59
63
|
name: 'model',
|
|
60
64
|
type: 'options',
|
|
61
|
-
typeOptions: {
|
|
62
|
-
loadOptionsMethod: 'getModels',
|
|
63
|
-
},
|
|
64
65
|
default: '',
|
|
65
66
|
description: 'The reranker model to use - models are loaded from your configured Ollama/Custom API',
|
|
67
|
+
typeOptions: {
|
|
68
|
+
loadOptions: {
|
|
69
|
+
routing: {
|
|
70
|
+
request: {
|
|
71
|
+
method: 'GET',
|
|
72
|
+
url: '/api/tags',
|
|
73
|
+
},
|
|
74
|
+
output: {
|
|
75
|
+
postReceive: [
|
|
76
|
+
{
|
|
77
|
+
type: 'rootProperty',
|
|
78
|
+
properties: {
|
|
79
|
+
property: 'models',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'setKeyValue',
|
|
84
|
+
properties: {
|
|
85
|
+
name: '={{$responseItem.name}}',
|
|
86
|
+
value: '={{$responseItem.name}}',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: 'sort',
|
|
91
|
+
properties: {
|
|
92
|
+
key: 'name',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: true,
|
|
66
101
|
},
|
|
67
102
|
// API Type selection
|
|
68
103
|
{
|
|
@@ -252,47 +287,6 @@ class OllamaRerankerWorkflow {
|
|
|
252
287
|
},
|
|
253
288
|
],
|
|
254
289
|
};
|
|
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
|
-
};
|
|
296
290
|
}
|
|
297
291
|
/**
|
|
298
292
|
* Execute Method (NOT supplyData!)
|
|
@@ -306,10 +300,10 @@ class OllamaRerankerWorkflow {
|
|
|
306
300
|
const returnData = [];
|
|
307
301
|
// Get credentials
|
|
308
302
|
const credentials = await this.getCredentials('ollamaApi');
|
|
309
|
-
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.
|
|
310
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Ollama
|
|
303
|
+
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.baseUrl)) {
|
|
304
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Ollama Base URL not configured. Please add Ollama API credentials.');
|
|
311
305
|
}
|
|
312
|
-
const ollamaHost = credentials.
|
|
306
|
+
const ollamaHost = credentials.baseUrl.replace(/\/$/, '');
|
|
313
307
|
// Get model
|
|
314
308
|
const model = this.getNodeParameter('model', 0);
|
|
315
309
|
if (!(model === null || model === void 0 ? void 0 : model.trim())) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-ollama-reranker",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
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",
|