n8n-nodes-ollama-reranker 1.3.0 → 1.3.1
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 +34 -44
- package/dist/nodes/OllamaRerankerWorkflow/OllamaRerankerWorkflow.node.d.ts +1 -10
- package/dist/nodes/OllamaRerankerWorkflow/OllamaRerankerWorkflow.node.js +35 -45
- 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
|
*
|
|
@@ -56,11 +56,42 @@ class OllamaReranker {
|
|
|
56
56
|
displayName: 'Model',
|
|
57
57
|
name: 'model',
|
|
58
58
|
type: 'options',
|
|
59
|
-
typeOptions: {
|
|
60
|
-
loadOptionsMethod: 'getModels',
|
|
61
|
-
},
|
|
62
59
|
default: '',
|
|
63
60
|
description: 'The reranker model to use - models are loaded from your configured Ollama/Custom API',
|
|
61
|
+
typeOptions: {
|
|
62
|
+
loadOptions: {
|
|
63
|
+
routing: {
|
|
64
|
+
request: {
|
|
65
|
+
method: 'GET',
|
|
66
|
+
url: '/api/tags',
|
|
67
|
+
},
|
|
68
|
+
output: {
|
|
69
|
+
postReceive: [
|
|
70
|
+
{
|
|
71
|
+
type: 'rootProperty',
|
|
72
|
+
properties: {
|
|
73
|
+
property: 'models',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'setKeyValue',
|
|
78
|
+
properties: {
|
|
79
|
+
name: '={{$responseItem.name}}',
|
|
80
|
+
value: '={{$responseItem.name}}',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'sort',
|
|
85
|
+
properties: {
|
|
86
|
+
key: 'name',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
required: true,
|
|
64
95
|
},
|
|
65
96
|
{
|
|
66
97
|
displayName: 'API Type',
|
|
@@ -151,47 +182,6 @@ class OllamaReranker {
|
|
|
151
182
|
},
|
|
152
183
|
],
|
|
153
184
|
};
|
|
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
185
|
}
|
|
196
186
|
/**
|
|
197
187
|
* Supply Data Method (NOT execute!)
|
|
@@ -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
|
*
|
|
@@ -53,16 +53,47 @@ class OllamaRerankerWorkflow {
|
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
55
|
properties: [
|
|
56
|
-
// Model selection with dynamic loading
|
|
56
|
+
// Model selection with dynamic loading (using routing like Ollama Chat Model)
|
|
57
57
|
{
|
|
58
58
|
displayName: 'Model',
|
|
59
59
|
name: 'model',
|
|
60
60
|
type: 'options',
|
|
61
|
-
typeOptions: {
|
|
62
|
-
loadOptionsMethod: 'getModels',
|
|
63
|
-
},
|
|
64
61
|
default: '',
|
|
65
62
|
description: 'The reranker model to use - models are loaded from your configured Ollama/Custom API',
|
|
63
|
+
typeOptions: {
|
|
64
|
+
loadOptions: {
|
|
65
|
+
routing: {
|
|
66
|
+
request: {
|
|
67
|
+
method: 'GET',
|
|
68
|
+
url: '/api/tags',
|
|
69
|
+
},
|
|
70
|
+
output: {
|
|
71
|
+
postReceive: [
|
|
72
|
+
{
|
|
73
|
+
type: 'rootProperty',
|
|
74
|
+
properties: {
|
|
75
|
+
property: 'models',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'setKeyValue',
|
|
80
|
+
properties: {
|
|
81
|
+
name: '={{$responseItem.name}}',
|
|
82
|
+
value: '={{$responseItem.name}}',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'sort',
|
|
87
|
+
properties: {
|
|
88
|
+
key: 'name',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
required: true,
|
|
66
97
|
},
|
|
67
98
|
// API Type selection
|
|
68
99
|
{
|
|
@@ -252,47 +283,6 @@ class OllamaRerankerWorkflow {
|
|
|
252
283
|
},
|
|
253
284
|
],
|
|
254
285
|
};
|
|
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
286
|
}
|
|
297
287
|
/**
|
|
298
288
|
* Execute Method (NOT supplyData!)
|
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.1",
|
|
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",
|