node-red-contrib-ollama 0.0.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/LICENSE +21 -0
- package/README.md +58 -0
- package/node-red-contrib-ollama-logo.png +0 -0
- package/nodes/ollama-chat.html +396 -0
- package/nodes/ollama-chat.js +23 -0
- package/nodes/ollama-copy.html +55 -0
- package/nodes/ollama-copy.js +23 -0
- package/nodes/ollama-create.html +90 -0
- package/nodes/ollama-create.js +23 -0
- package/nodes/ollama-delete.html +48 -0
- package/nodes/ollama-delete.js +23 -0
- package/nodes/ollama-embeddings.html +268 -0
- package/nodes/ollama-embeddings.js +23 -0
- package/nodes/ollama-generate.html +380 -0
- package/nodes/ollama-generate.js +23 -0
- package/nodes/ollama-list.html +123 -0
- package/nodes/ollama-list.js +22 -0
- package/nodes/ollama-pull.html +83 -0
- package/nodes/ollama-pull.js +23 -0
- package/nodes/ollama-push.html +83 -0
- package/nodes/ollama-push.js +23 -0
- package/nodes/ollama-show.html +178 -0
- package/nodes/ollama-show.js +23 -0
- package/package.json +36 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType( 'ollama-generate', {
|
|
3
|
+
category: 'AI',
|
|
4
|
+
color: 'rgb(186 230 253)',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
},
|
|
8
|
+
inputs: 1,
|
|
9
|
+
outputs: 1,
|
|
10
|
+
icon: 'ollama.png',
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || 'ollama-generate';
|
|
13
|
+
},
|
|
14
|
+
} )
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="ollama-generate">
|
|
18
|
+
<div class="form-row">
|
|
19
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
21
|
+
</div>
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script type="text/html" data-help-name="ollama-generate">
|
|
25
|
+
<p>Generate a response for a given prompt with a provided model.</p>
|
|
26
|
+
|
|
27
|
+
<h3>Inputs</h3>
|
|
28
|
+
|
|
29
|
+
<dl class="message-properties">
|
|
30
|
+
<dt>
|
|
31
|
+
payload.model
|
|
32
|
+
|
|
33
|
+
<span class="property-type">string</span>
|
|
34
|
+
</dt>
|
|
35
|
+
<dd>The model to use for generating the next message.</dd>
|
|
36
|
+
|
|
37
|
+
<dt>
|
|
38
|
+
payload.prompt
|
|
39
|
+
|
|
40
|
+
<span class="property-type">string</span>
|
|
41
|
+
</dt>
|
|
42
|
+
<dd>The prompt to generate a response for.</dd>
|
|
43
|
+
|
|
44
|
+
<dt class="optional">
|
|
45
|
+
payload.images
|
|
46
|
+
|
|
47
|
+
<span class="property-type">array</span>
|
|
48
|
+
</dt>
|
|
49
|
+
<dd>Images to be included, either as Uint8Array or base64 encoded strings.</dd>
|
|
50
|
+
|
|
51
|
+
<dt class="optional">
|
|
52
|
+
payload.system
|
|
53
|
+
|
|
54
|
+
<span class="property-type">string</span>
|
|
55
|
+
</dt>
|
|
56
|
+
<dd>Override the model system prompt.</dd>
|
|
57
|
+
|
|
58
|
+
<dt class="optional">
|
|
59
|
+
payload.template
|
|
60
|
+
|
|
61
|
+
<span class="property-type">string</span>
|
|
62
|
+
</dt>
|
|
63
|
+
<dd>Override the model template.</dd>
|
|
64
|
+
|
|
65
|
+
<dt class="optional">
|
|
66
|
+
payload.raw
|
|
67
|
+
|
|
68
|
+
<span class="property-type">boolean</span>
|
|
69
|
+
</dt>
|
|
70
|
+
<dd>Bypass the prompt template and pass the prompt directly to the model.</dd>
|
|
71
|
+
|
|
72
|
+
<dt class="optional">
|
|
73
|
+
payload.format
|
|
74
|
+
|
|
75
|
+
<span class="property-type">string</span>
|
|
76
|
+
</dt>
|
|
77
|
+
<dd>Set the expected format of the response (<code>json</code>).</dd>
|
|
78
|
+
|
|
79
|
+
<dt class="optional">
|
|
80
|
+
payload.stream
|
|
81
|
+
|
|
82
|
+
<span class="property-type">boolean</span>
|
|
83
|
+
</dt>
|
|
84
|
+
<dd>When true an AsyncGenerator is returned.</dd>
|
|
85
|
+
|
|
86
|
+
<dt class="optional">
|
|
87
|
+
payload.keep_alive
|
|
88
|
+
|
|
89
|
+
<span class="property-type">string | number</span>
|
|
90
|
+
</dt>
|
|
91
|
+
<dd>How long to keep the model loaded.</dd>
|
|
92
|
+
|
|
93
|
+
<dt class="optional">
|
|
94
|
+
payload.options
|
|
95
|
+
|
|
96
|
+
<span class="property-type">object</span>
|
|
97
|
+
</dt>
|
|
98
|
+
<dd>
|
|
99
|
+
Options to configure the runtime.<br />
|
|
100
|
+
|
|
101
|
+
<h4>Options</h4>
|
|
102
|
+
<dl class="message-properties">
|
|
103
|
+
<dt>
|
|
104
|
+
numa
|
|
105
|
+
|
|
106
|
+
<span class="property-type">boolean</span>
|
|
107
|
+
</dt>
|
|
108
|
+
<dd>Use NUMA for the runtime.</dd>
|
|
109
|
+
|
|
110
|
+
<dt>
|
|
111
|
+
num_ctx
|
|
112
|
+
|
|
113
|
+
<span class="property-type">number</span>
|
|
114
|
+
</dt>
|
|
115
|
+
<dd>The number of contexts to use.</dd>
|
|
116
|
+
|
|
117
|
+
<dt>
|
|
118
|
+
num_batch
|
|
119
|
+
|
|
120
|
+
<span class="property-type">number</span>
|
|
121
|
+
</dt>
|
|
122
|
+
<dd>The number of batches to use.</dd>
|
|
123
|
+
|
|
124
|
+
<dt>
|
|
125
|
+
main_gpu
|
|
126
|
+
|
|
127
|
+
<span class="property-type">number</span>
|
|
128
|
+
</dt>
|
|
129
|
+
<dd>The main GPU to use.</dd>
|
|
130
|
+
|
|
131
|
+
<dt>
|
|
132
|
+
low_vram
|
|
133
|
+
|
|
134
|
+
<span class="property-type">boolean</span>
|
|
135
|
+
</dt>
|
|
136
|
+
<dd>Use low VRAM.</dd>
|
|
137
|
+
|
|
138
|
+
<dt>
|
|
139
|
+
f16_kv
|
|
140
|
+
|
|
141
|
+
<span class="property-type">boolean</span>
|
|
142
|
+
</dt>
|
|
143
|
+
<dd>Use f16 key-value.</dd>
|
|
144
|
+
|
|
145
|
+
<dt>
|
|
146
|
+
logits_all
|
|
147
|
+
|
|
148
|
+
<span class="property-type">boolean</span>
|
|
149
|
+
</dt>
|
|
150
|
+
<dd>Return all logits.</dd>
|
|
151
|
+
|
|
152
|
+
<dt>
|
|
153
|
+
vocab_only
|
|
154
|
+
|
|
155
|
+
<span class="property-type">boolean</span>
|
|
156
|
+
</dt>
|
|
157
|
+
<dd>Return only the vocabulary.</dd>
|
|
158
|
+
|
|
159
|
+
<dt>
|
|
160
|
+
use_nmap
|
|
161
|
+
|
|
162
|
+
<span class="property-type">boolean</span>
|
|
163
|
+
</dt>
|
|
164
|
+
<dd>Use NMAP.</dd>
|
|
165
|
+
|
|
166
|
+
<dt>
|
|
167
|
+
use_mlock
|
|
168
|
+
|
|
169
|
+
<span class="property-type">boolean</span>
|
|
170
|
+
</dt>
|
|
171
|
+
<dd>Use mlock.</dd>
|
|
172
|
+
|
|
173
|
+
<dt>
|
|
174
|
+
embedding_only
|
|
175
|
+
|
|
176
|
+
<span class="property-type">boolean</span>
|
|
177
|
+
</dt>
|
|
178
|
+
<dd>Return only the embeddings.</dd>
|
|
179
|
+
|
|
180
|
+
<dt>
|
|
181
|
+
num_thread
|
|
182
|
+
|
|
183
|
+
<span class="property-type">number</span>
|
|
184
|
+
</dt>
|
|
185
|
+
<dd>The number of threads to use.</dd>
|
|
186
|
+
|
|
187
|
+
<dt>
|
|
188
|
+
num_keep
|
|
189
|
+
|
|
190
|
+
<span class="property-type">number</span>
|
|
191
|
+
</dt>
|
|
192
|
+
<dd>The number of models to keep.</dd>
|
|
193
|
+
|
|
194
|
+
<dt>
|
|
195
|
+
seed
|
|
196
|
+
|
|
197
|
+
<span class="property-type">number</span>
|
|
198
|
+
</dt>
|
|
199
|
+
<dd>The seed to use.</dd>
|
|
200
|
+
|
|
201
|
+
<dt>
|
|
202
|
+
num_predict
|
|
203
|
+
|
|
204
|
+
<span class="property-type">number</span>
|
|
205
|
+
</dt>
|
|
206
|
+
<dd>The number of predictions to use.</dd>
|
|
207
|
+
|
|
208
|
+
<dt>
|
|
209
|
+
top_k
|
|
210
|
+
|
|
211
|
+
<span class="property-type">number</span>
|
|
212
|
+
</dt>
|
|
213
|
+
<dd>The top k to use.</dd>
|
|
214
|
+
|
|
215
|
+
<dt>
|
|
216
|
+
top_p
|
|
217
|
+
|
|
218
|
+
<span class="property-type">number</span>
|
|
219
|
+
</dt>
|
|
220
|
+
<dd>The top p to use.</dd>
|
|
221
|
+
|
|
222
|
+
<dt>
|
|
223
|
+
typical_p
|
|
224
|
+
|
|
225
|
+
<span class="property-type">number</span>
|
|
226
|
+
</dt>
|
|
227
|
+
<dd>The typical p to use.</dd>
|
|
228
|
+
|
|
229
|
+
<dt>
|
|
230
|
+
repeat_last_n
|
|
231
|
+
|
|
232
|
+
<span class="property-type">number</span>
|
|
233
|
+
</dt>
|
|
234
|
+
<dd>The repeat last n to use.</dd>
|
|
235
|
+
|
|
236
|
+
<dt>
|
|
237
|
+
temperature
|
|
238
|
+
|
|
239
|
+
<span class="property-type">number</span>
|
|
240
|
+
</dt>
|
|
241
|
+
<dd>The temperature to use.</dd>
|
|
242
|
+
|
|
243
|
+
<dt>
|
|
244
|
+
repeat_pentalty
|
|
245
|
+
|
|
246
|
+
<span class="property-type">number</span>
|
|
247
|
+
</dt>
|
|
248
|
+
<dd>The repeat pentalty to use.</dd>
|
|
249
|
+
|
|
250
|
+
<dt>
|
|
251
|
+
presence_penalty
|
|
252
|
+
|
|
253
|
+
<span class="property-type">number</span>
|
|
254
|
+
</dt>
|
|
255
|
+
<dd>The presence penalty to use.</dd>
|
|
256
|
+
|
|
257
|
+
<dt>
|
|
258
|
+
frequency_penalty
|
|
259
|
+
|
|
260
|
+
<span class="property-type">number</span>
|
|
261
|
+
</dt>
|
|
262
|
+
<dd>The frequency penalty to use.</dd>
|
|
263
|
+
|
|
264
|
+
<dt>
|
|
265
|
+
mirostat
|
|
266
|
+
|
|
267
|
+
<span class="property-type">boolean</span>
|
|
268
|
+
</dt>
|
|
269
|
+
<dd>Use mirostat.</dd>
|
|
270
|
+
|
|
271
|
+
<dt>
|
|
272
|
+
mirostat_tau
|
|
273
|
+
|
|
274
|
+
<span class="property-type">number</span>
|
|
275
|
+
</dt>
|
|
276
|
+
|
|
277
|
+
<dt>
|
|
278
|
+
mirostat_eta
|
|
279
|
+
|
|
280
|
+
<span class="property-type">number</span>
|
|
281
|
+
</dt>
|
|
282
|
+
|
|
283
|
+
<dt>
|
|
284
|
+
penalize_newline
|
|
285
|
+
|
|
286
|
+
<span class="property-type">boolean</span>
|
|
287
|
+
</dt>
|
|
288
|
+
<dd>Penalize newline.</dd>
|
|
289
|
+
|
|
290
|
+
<dt>
|
|
291
|
+
stop
|
|
292
|
+
|
|
293
|
+
<span class="property-type">array</span>
|
|
294
|
+
</dt>
|
|
295
|
+
<dd>The stop to use.</dd>
|
|
296
|
+
</dl>
|
|
297
|
+
</dd>
|
|
298
|
+
</dl>
|
|
299
|
+
|
|
300
|
+
<h3>Outputs</h3>
|
|
301
|
+
|
|
302
|
+
<dl class="message-properties">
|
|
303
|
+
<dt>
|
|
304
|
+
payload.model
|
|
305
|
+
|
|
306
|
+
<span class="property-type">string</span>
|
|
307
|
+
</dt>
|
|
308
|
+
<dd>The model used for generating the next message.</dd>
|
|
309
|
+
|
|
310
|
+
<dt>
|
|
311
|
+
payload.created_at
|
|
312
|
+
|
|
313
|
+
<span class="property-type">Date</span>
|
|
314
|
+
</dt>
|
|
315
|
+
<dd>The date and time the model was created.</dd>
|
|
316
|
+
|
|
317
|
+
<dt>
|
|
318
|
+
payload.response
|
|
319
|
+
|
|
320
|
+
<span class="property-type">string</span>
|
|
321
|
+
</dt>
|
|
322
|
+
<dd>The generated response.</dd>
|
|
323
|
+
|
|
324
|
+
<dt>
|
|
325
|
+
payload.done
|
|
326
|
+
|
|
327
|
+
<span class="property-type">boolean</span>
|
|
328
|
+
</dt>
|
|
329
|
+
<dd>Whether the generation is complete.</dd>
|
|
330
|
+
|
|
331
|
+
<dt>
|
|
332
|
+
payload.context
|
|
333
|
+
|
|
334
|
+
<span class="property-type">array</span>
|
|
335
|
+
</dt>
|
|
336
|
+
<dd>The context used for generating the next message.</dd>
|
|
337
|
+
|
|
338
|
+
<dt>
|
|
339
|
+
payload.total_duraion
|
|
340
|
+
|
|
341
|
+
<span class="property-type">number</span>
|
|
342
|
+
</dt>
|
|
343
|
+
<dd>The total duration of the generation.</dd>
|
|
344
|
+
|
|
345
|
+
<dt>
|
|
346
|
+
payload.load_duration
|
|
347
|
+
|
|
348
|
+
<span class="property-type">number</span>
|
|
349
|
+
</dt>
|
|
350
|
+
<dd>The duration of loading the model.</dd>
|
|
351
|
+
|
|
352
|
+
<dt>
|
|
353
|
+
payload.prompt_eval_count
|
|
354
|
+
|
|
355
|
+
<span class="property-type">number</span>
|
|
356
|
+
</dt>
|
|
357
|
+
<dd>The number of prompt evaluations.</dd>
|
|
358
|
+
|
|
359
|
+
<dt>
|
|
360
|
+
payload.prompt_eval_duration
|
|
361
|
+
|
|
362
|
+
<span class="property-type">number</span>
|
|
363
|
+
</dt>
|
|
364
|
+
<dd>The duration of prompt evaluations.</dd>
|
|
365
|
+
|
|
366
|
+
<dt>
|
|
367
|
+
payload.eval_count
|
|
368
|
+
|
|
369
|
+
<span class="property-type">number</span>
|
|
370
|
+
</dt>
|
|
371
|
+
<dd>The number of evaluations.</dd>
|
|
372
|
+
|
|
373
|
+
<dt>
|
|
374
|
+
payload.eval_duration
|
|
375
|
+
|
|
376
|
+
<span class="property-type">number</span>
|
|
377
|
+
</dt>
|
|
378
|
+
<dd>The duration of evaluations.</dd>
|
|
379
|
+
</dl>
|
|
380
|
+
</script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module.exports = function( RED ) {
|
|
2
|
+
const { Ollama } = require( 'ollama' )
|
|
3
|
+
|
|
4
|
+
function OllamaGenerateNode( config ) {
|
|
5
|
+
RED.nodes.createNode( this, config )
|
|
6
|
+
const node = this
|
|
7
|
+
|
|
8
|
+
node.on( 'input', async function( msg ) {
|
|
9
|
+
const ollama = new Ollama()
|
|
10
|
+
const { model, prompt, images, format, options, system, template, context, stream, raw, keep_alive } = msg.payload
|
|
11
|
+
|
|
12
|
+
const response = await ollama.generate( { model, prompt, images, format, options, system, template, context, stream, raw, keep_alive } )
|
|
13
|
+
.catch( error => {
|
|
14
|
+
node.error( error )
|
|
15
|
+
} )
|
|
16
|
+
|
|
17
|
+
msg.payload = response
|
|
18
|
+
node.send( msg )
|
|
19
|
+
} )
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
RED.nodes.registerType( 'ollama-generate', OllamaGenerateNode )
|
|
23
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType( 'ollama-list', {
|
|
3
|
+
category: 'AI',
|
|
4
|
+
color: 'rgb(186 230 253)',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
},
|
|
8
|
+
inputs: 1,
|
|
9
|
+
outputs: 1,
|
|
10
|
+
icon: 'ollama.png',
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || 'ollama-list';
|
|
13
|
+
},
|
|
14
|
+
} )
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="ollama-list">
|
|
18
|
+
<div class="form-row">
|
|
19
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
21
|
+
</div>
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script type="text/html" data-help-name="ollama-list">
|
|
25
|
+
<p>List models that are available locally.</p>
|
|
26
|
+
|
|
27
|
+
<h3>Outputs</h3>
|
|
28
|
+
|
|
29
|
+
<dl class="message-properties">
|
|
30
|
+
<dt>
|
|
31
|
+
payload.models
|
|
32
|
+
|
|
33
|
+
<span class="property-type">array</span>
|
|
34
|
+
</dt>
|
|
35
|
+
<dd>
|
|
36
|
+
The list of models that are available locally.<br />
|
|
37
|
+
|
|
38
|
+
<h4>Model</h4>
|
|
39
|
+
<dl class="message-properties">
|
|
40
|
+
<dt>
|
|
41
|
+
name
|
|
42
|
+
|
|
43
|
+
<span class="property-type">string</span>
|
|
44
|
+
</dt>
|
|
45
|
+
<dd>The name of the model.</dd>
|
|
46
|
+
|
|
47
|
+
<dt>
|
|
48
|
+
modified_at
|
|
49
|
+
|
|
50
|
+
<span class="property-type">Date</span>
|
|
51
|
+
</dt>
|
|
52
|
+
<dd>The date the model was last modified.</dd>
|
|
53
|
+
|
|
54
|
+
<dt>
|
|
55
|
+
size
|
|
56
|
+
|
|
57
|
+
<span class="property-type">number</span>
|
|
58
|
+
</dt>
|
|
59
|
+
<dd>The size of the model in bytes.</dd>
|
|
60
|
+
|
|
61
|
+
<dt>
|
|
62
|
+
digest
|
|
63
|
+
|
|
64
|
+
<span class="property-type">string</span>
|
|
65
|
+
</dt>
|
|
66
|
+
<dd>The digest of the model.</dd>
|
|
67
|
+
|
|
68
|
+
<dt>
|
|
69
|
+
details
|
|
70
|
+
|
|
71
|
+
<span class="property-type">object</span>
|
|
72
|
+
</dt>
|
|
73
|
+
<dd>
|
|
74
|
+
The details of the model.<br />
|
|
75
|
+
|
|
76
|
+
<h5>Details</h5>
|
|
77
|
+
<dl class="message-properties">
|
|
78
|
+
<dt>
|
|
79
|
+
parent_model
|
|
80
|
+
|
|
81
|
+
<span class="property-type">string</span>
|
|
82
|
+
</dt>
|
|
83
|
+
<dd>The parent model of the model.</dd>
|
|
84
|
+
|
|
85
|
+
<dt>
|
|
86
|
+
format
|
|
87
|
+
|
|
88
|
+
<span class="property-type">string</span>
|
|
89
|
+
</dt>
|
|
90
|
+
<dd>The format of the model.</dd>
|
|
91
|
+
|
|
92
|
+
<dt>
|
|
93
|
+
family
|
|
94
|
+
|
|
95
|
+
<span class="property-type">string</span>
|
|
96
|
+
</dt>
|
|
97
|
+
<dd>The family of the model.</dd>
|
|
98
|
+
|
|
99
|
+
<dt>
|
|
100
|
+
families
|
|
101
|
+
|
|
102
|
+
<span class="property-type">array</span>
|
|
103
|
+
</dt>
|
|
104
|
+
<dd>The families of the model.</dd>
|
|
105
|
+
|
|
106
|
+
<dt>
|
|
107
|
+
parameter_size
|
|
108
|
+
|
|
109
|
+
<span class="property-type">string</span>
|
|
110
|
+
</dt>
|
|
111
|
+
<dd>The parameter size of the model.</dd>
|
|
112
|
+
|
|
113
|
+
<dt>
|
|
114
|
+
quiantization_level
|
|
115
|
+
|
|
116
|
+
<span class="property-type">string</span>
|
|
117
|
+
</dt>
|
|
118
|
+
<dd>The quantization level of the model.</dd>
|
|
119
|
+
</dl>
|
|
120
|
+
</dd>
|
|
121
|
+
</dl>
|
|
122
|
+
</dd>
|
|
123
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = function( RED ) {
|
|
2
|
+
const { Ollama } = require( 'ollama' )
|
|
3
|
+
|
|
4
|
+
function OllamaListNode( config ) {
|
|
5
|
+
RED.nodes.createNode( this, config )
|
|
6
|
+
const node = this
|
|
7
|
+
|
|
8
|
+
node.on( 'input', async function( msg ) {
|
|
9
|
+
const ollama = new Ollama()
|
|
10
|
+
|
|
11
|
+
const response = await ollama.list()
|
|
12
|
+
.catch( error => {
|
|
13
|
+
node.error( error )
|
|
14
|
+
} )
|
|
15
|
+
|
|
16
|
+
msg.payload = response
|
|
17
|
+
node.send( msg )
|
|
18
|
+
} )
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
RED.nodes.registerType( 'ollama-list', OllamaListNode )
|
|
22
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType( 'ollama-pull', {
|
|
3
|
+
category: 'AI',
|
|
4
|
+
color: 'rgb(186 230 253)',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
},
|
|
8
|
+
inputs: 1,
|
|
9
|
+
outputs: 1,
|
|
10
|
+
icon: 'ollama.png',
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || 'ollama-pull';
|
|
13
|
+
},
|
|
14
|
+
} )
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="ollama-pull">
|
|
18
|
+
<div class="form-row">
|
|
19
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
21
|
+
</div>
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script type="text/html" data-help-name="ollama-pull">
|
|
25
|
+
<p>Download a model from the ollama library.</p>
|
|
26
|
+
|
|
27
|
+
<h3>Inputs</h3>
|
|
28
|
+
|
|
29
|
+
<dl class="message-properties">
|
|
30
|
+
<dt>
|
|
31
|
+
payload.model
|
|
32
|
+
|
|
33
|
+
<span class="property-type">string</span>
|
|
34
|
+
</dt>
|
|
35
|
+
<dd>The name of the model to download.</dd>
|
|
36
|
+
|
|
37
|
+
<dt>
|
|
38
|
+
payload.insecure
|
|
39
|
+
|
|
40
|
+
<span class="property-type">boolean</span>
|
|
41
|
+
</dt>
|
|
42
|
+
<dd>Pull from servers whose identity cannot be verified.</dd>
|
|
43
|
+
|
|
44
|
+
<dt>
|
|
45
|
+
payload.stream
|
|
46
|
+
|
|
47
|
+
<span class="property-type">boolean</span>
|
|
48
|
+
</dt>
|
|
49
|
+
<dd>When true an AsyncGenerator is returned.</dd>
|
|
50
|
+
</dl>
|
|
51
|
+
|
|
52
|
+
<h3>Outputs</h3>
|
|
53
|
+
|
|
54
|
+
<dl class="message-properties">
|
|
55
|
+
<dt>
|
|
56
|
+
payload.status
|
|
57
|
+
|
|
58
|
+
<span class="property-type">string</span>
|
|
59
|
+
</dt>
|
|
60
|
+
<dd>The progress status.</dd>
|
|
61
|
+
|
|
62
|
+
<dt>
|
|
63
|
+
payload.digest
|
|
64
|
+
|
|
65
|
+
<span class="property-type">string</span>
|
|
66
|
+
</dt>
|
|
67
|
+
<dd>The progress digest.</dd>
|
|
68
|
+
|
|
69
|
+
<dt>
|
|
70
|
+
payload.total
|
|
71
|
+
|
|
72
|
+
<span class="property-type">number</span>
|
|
73
|
+
</dt>
|
|
74
|
+
<dd>The total progress.</dd>
|
|
75
|
+
|
|
76
|
+
<dt>
|
|
77
|
+
payload.completed
|
|
78
|
+
|
|
79
|
+
<span class="property-type">number</span>
|
|
80
|
+
</dt>
|
|
81
|
+
<dd>The completed progress.</dd>
|
|
82
|
+
</dl>
|
|
83
|
+
</script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module.exports = function( RED ) {
|
|
2
|
+
const { Ollama } = require( 'ollama' )
|
|
3
|
+
|
|
4
|
+
function OllamaPulltNode( config ) {
|
|
5
|
+
RED.nodes.createNode( this, config )
|
|
6
|
+
const node = this
|
|
7
|
+
|
|
8
|
+
node.on( 'input', async function( msg ) {
|
|
9
|
+
const ollama = new Ollama()
|
|
10
|
+
const { model, insecure, stream } = msg.payload
|
|
11
|
+
|
|
12
|
+
const response = await ollama.pull( { model, insecure, stream } )
|
|
13
|
+
.catch( error => {
|
|
14
|
+
node.error( error )
|
|
15
|
+
} )
|
|
16
|
+
|
|
17
|
+
msg.payload = response
|
|
18
|
+
node.send( msg )
|
|
19
|
+
} )
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
RED.nodes.registerType( 'ollama-pull', OllamaPulltNode )
|
|
23
|
+
}
|