node-red-contrib-ollama 0.2.0 → 0.2.3

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.
@@ -3,7 +3,9 @@
3
3
  category: 'AI',
4
4
  color: 'rgb(186 230 253)',
5
5
  defaults: {
6
- name: { value: '' },
6
+ name: { value: 'Ollama Embed' },
7
+ server: { value: '', type: 'ollama-config-server', required: false },
8
+ model: { value: '', type: 'ollama-config-model', required: false },
7
9
  },
8
10
  inputs: 1,
9
11
  outputs: 1,
@@ -19,6 +21,16 @@
19
21
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
20
22
  <input type="text" id="node-input-name" placeholder="Name" />
21
23
  </div>
24
+
25
+ <div class="form-row">
26
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
27
+ <input type="text" id="node-input-server" />
28
+ </div>
29
+
30
+ <div class="form-row">
31
+ <label for="node-input-model"><i class="fa fa-bookmark"></i> Model</label>
32
+ <input type="text" id="node-input-model" />
33
+ </div>
22
34
  </script>
23
35
 
24
36
  <script type="text/html" data-help-name="ollama-embed">
@@ -27,244 +39,192 @@
27
39
  <h3>Inputs</h3>
28
40
 
29
41
  <dl class="message-properties">
30
- <dt>
31
- payload.host
32
-
33
- <span class="property-type">string</span>
34
- </dt>
35
- <dd>The host of the Ollama instance.</dd>
36
-
37
- <dt>
38
- payload.model
39
-
40
- <span class="property-type">string</span>
41
- </dt>
42
- <dd>The name of the model used to generate the embeddings.</dd>
43
-
44
- <dt>
45
- payload.input
46
-
47
- <span class="property-type">string | array[string]</span>
48
- </dt>
49
- <dd>The input used to generate the embeddings.</dd>
50
-
51
42
  <dt class="optional">
52
- payload.truncate
53
-
54
- <span class="property-type">boolean</span>
43
+ payload <span class="property-type">object</span>
55
44
  </dt>
56
- <dd>Truncate the input to fit the maximum context length supported by the model.</dd>
57
-
58
- <dt class="optional">
59
- payload.keep_alive
60
-
61
- <span class="property-type">string | number</span>
62
- </dt>
63
- <dd>How long to keep the model loaded.</dd>
64
-
65
- <dt class="optional">
66
- payload.options
67
45
 
68
- <span class="property-type">object</span>
69
- </dt>
70
46
  <dd>
71
- Options to configure the runtime.<br />
47
+ The payload object.
72
48
 
73
- <h4>Options</h4>
74
49
  <dl class="message-properties">
75
- <dt>
76
- numa
77
-
78
- <span class="property-type">boolean</span>
79
- </dt>
80
- <dd>Use NUMA for the runtime.</dd>
81
-
82
- <dt>
83
- num_ctx
84
-
85
- <span class="property-type">number</span>
86
- </dt>
87
- <dd>The number of contexts to use.</dd>
88
-
89
- <dt>
90
- num_batch
91
-
92
- <span class="property-type">number</span>
93
- </dt>
94
- <dd>The number of batches to use.</dd>
95
-
96
- <dt>
97
- main_gpu
98
-
99
- <span class="property-type">number</span>
100
- </dt>
101
- <dd>The main GPU to use.</dd>
102
-
103
- <dt>
104
- low_vram
105
-
106
- <span class="property-type">boolean</span>
107
- </dt>
108
- <dd>Use low VRAM.</dd>
109
-
110
- <dt>
111
- f16_kv
112
-
113
- <span class="property-type">boolean</span>
114
- </dt>
115
- <dd>Use f16 key-value.</dd>
116
-
117
- <dt>
118
- logits_all
119
-
120
- <span class="property-type">boolean</span>
50
+ <dt class="optional">
51
+ payload.host <span class="property-type">string</span>
121
52
  </dt>
122
- <dd>Return all logits.</dd>
123
-
124
- <dt>
125
- vocab_only
126
-
127
- <span class="property-type">boolean</span>
128
- </dt>
129
- <dd>Return only the vocabulary.</dd>
130
-
131
- <dt>
132
- use_nmap
133
-
134
- <span class="property-type">boolean</span>
135
- </dt>
136
- <dd>Use NMAP.</dd>
137
-
138
- <dt>
139
- use_mlock
140
-
141
- <span class="property-type">boolean</span>
142
- </dt>
143
- <dd>Use mlock.</dd>
144
-
145
- <dt>
146
- embedding_only
147
-
148
- <span class="property-type">boolean</span>
53
+ <dd>
54
+ The host of the Ollama instance.<br />
55
+ <em>Alternative to the <code>Server</code> field.</em>
56
+ </dd>
57
+
58
+ <dt class="optional">
59
+ payload.model <span class="property-type">string</span>
149
60
  </dt>
150
- <dd>Return only the embeddings.</dd>
151
-
152
- <dt>
153
- num_thread
154
-
155
- <span class="property-type">number</span>
156
- </dt>
157
- <dd>The number of threads to use.</dd>
158
-
159
- <dt>
160
- num_keep
161
-
162
- <span class="property-type">number</span>
163
- </dt>
164
- <dd>The number of models to keep.</dd>
165
-
166
- <dt>
167
- seed
168
-
169
- <span class="property-type">number</span>
170
- </dt>
171
- <dd>The seed to use.</dd>
172
-
173
- <dt>
174
- num_predict
175
-
176
- <span class="property-type">number</span>
177
- </dt>
178
- <dd>The number of predictions to use.</dd>
179
-
180
- <dt>
181
- top_k
182
-
183
- <span class="property-type">number</span>
184
- </dt>
185
- <dd>The top k to use.</dd>
186
-
187
- <dt>
188
- top_p
189
-
190
- <span class="property-type">number</span>
191
- </dt>
192
- <dd>The top p to use.</dd>
193
-
194
- <dt>
195
- typical_p
196
-
197
- <span class="property-type">number</span>
198
- </dt>
199
- <dd>The typical p to use.</dd>
200
-
201
- <dt>
202
- repeat_last_n
203
-
204
- <span class="property-type">number</span>
205
- </dt>
206
- <dd>The repeat last n to use.</dd>
207
-
208
- <dt>
209
- temperature
210
-
211
- <span class="property-type">number</span>
212
- </dt>
213
- <dd>The temperature to use.</dd>
214
-
215
- <dt>
216
- repeat_pentalty
217
-
218
- <span class="property-type">number</span>
219
- </dt>
220
- <dd>The repeat pentalty to use.</dd>
221
-
222
- <dt>
223
- presence_penalty
224
-
225
- <span class="property-type">number</span>
226
- </dt>
227
- <dd>The presence penalty to use.</dd>
228
-
229
- <dt>
230
- frequency_penalty
231
-
232
- <span class="property-type">number</span>
233
- </dt>
234
- <dd>The frequency penalty to use.</dd>
235
-
236
- <dt>
237
- mirostat
238
-
239
- <span class="property-type">boolean</span>
240
- </dt>
241
- <dd>Use mirostat.</dd>
242
-
243
- <dt>
244
- mirostat_tau
245
-
246
- <span class="property-type">number</span>
247
- </dt>
248
-
249
- <dt>
250
- mirostat_eta
251
-
252
- <span class="property-type">number</span>
253
- </dt>
254
-
255
- <dt>
256
- penalize_newline
257
-
258
- <span class="property-type">boolean</span>
259
- </dt>
260
- <dd>Penalize newline.</dd>
261
-
262
- <dt>
263
- stop
264
-
265
- <span class="property-type">array</span>
61
+ <dd>
62
+ The name of the model used to generate the embeddings.<br />
63
+ <em>Alternative to the <code>Model</code> field.</em>
64
+ </dd>
65
+
66
+ <dt>
67
+ payload.input <span class="property-type">string | array[string]</span>
266
68
  </dt>
267
- <dd>The stop to use.</dd>
69
+ <dd>The input used to generate the embeddings.</dd>
70
+
71
+ <dt class="optional">
72
+ payload.truncate <span class="property-type">boolean</span>
73
+ </dt>
74
+ <dd>Truncate the input to fit the maximum context length supported by the model.</dd>
75
+
76
+ <dt class="optional">
77
+ payload.keep_alive <span class="property-type">string | number</span>
78
+ </dt>
79
+ <dd>How long to keep the model loaded.</dd>
80
+
81
+ <dt class="optional">
82
+ payload.options <span class="property-type">object</span>
83
+ </dt>
84
+ <dd>
85
+ Options to configure the runtime.<br />
86
+
87
+ <h4>Options</h4>
88
+ <dl class="message-properties">
89
+ <dt>
90
+ numa <span class="property-type">boolean</span>
91
+ </dt>
92
+ <dd>Use NUMA for the runtime.</dd>
93
+
94
+ <dt>
95
+ num_ctx <span class="property-type">number</span>
96
+ </dt>
97
+ <dd>The number of contexts to use.</dd>
98
+
99
+ <dt>
100
+ num_batch <span class="property-type">number</span>
101
+ </dt>
102
+ <dd>The number of batches to use.</dd>
103
+
104
+ <dt>
105
+ main_gpu <span class="property-type">number</span>
106
+ </dt>
107
+ <dd>The main GPU to use.</dd>
108
+
109
+ <dt>
110
+ low_vram <span class="property-type">boolean</span>
111
+ </dt>
112
+ <dd>Use low VRAM.</dd>
113
+
114
+ <dt>
115
+ f16_kv <span class="property-type">boolean</span>
116
+ </dt>
117
+ <dd>Use f16 key-value.</dd>
118
+
119
+ <dt>
120
+ logits_all <span class="property-type">boolean</span>
121
+ </dt>
122
+ <dd>Return all logits.</dd>
123
+
124
+ <dt>
125
+ vocab_only <span class="property-type">boolean</span>
126
+ </dt>
127
+ <dd>Return only the vocabulary.</dd>
128
+
129
+ <dt>
130
+ use_nmap <span class="property-type">boolean</span>
131
+ </dt>
132
+ <dd>Use NMAP.</dd>
133
+
134
+ <dt>
135
+ use_mlock <span class="property-type">boolean</span>
136
+ </dt>
137
+ <dd>Use mlock.</dd>
138
+
139
+ <dt>
140
+ embedding_only <span class="property-type">boolean</span>
141
+ </dt>
142
+ <dd>Return only the embeddings.</dd>
143
+
144
+ <dt>
145
+ num_thread <span class="property-type">number</span>
146
+ </dt>
147
+ <dd>The number of threads to use.</dd>
148
+
149
+ <dt>
150
+ num_keep <span class="property-type">number</span>
151
+ </dt>
152
+ <dd>The number of models to keep.</dd>
153
+
154
+ <dt>
155
+ seed <span class="property-type">number</span>
156
+ </dt>
157
+ <dd>The seed to use.</dd>
158
+
159
+ <dt>
160
+ num_predict <span class="property-type">number</span>
161
+ </dt>
162
+ <dd>The number of predictions to use.</dd>
163
+
164
+ <dt>
165
+ top_k <span class="property-type">number</span>
166
+ </dt>
167
+ <dd>The top k to use.</dd>
168
+
169
+ <dt>
170
+ top_p <span class="property-type">number</span>
171
+ </dt>
172
+ <dd>The top p to use.</dd>
173
+
174
+ <dt>
175
+ typical_p <span class="property-type">number</span>
176
+ </dt>
177
+ <dd>The typical p to use.</dd>
178
+
179
+ <dt>
180
+ repeat_last_n <span class="property-type">number</span>
181
+ </dt>
182
+ <dd>The repeat last n to use.</dd>
183
+
184
+ <dt>
185
+ temperature <span class="property-type">number</span>
186
+ </dt>
187
+ <dd>The temperature to use.</dd>
188
+
189
+ <dt>
190
+ repeat_pentalty <span class="property-type">number</span>
191
+ </dt>
192
+ <dd>The repeat pentalty to use.</dd>
193
+
194
+ <dt>
195
+ presence_penalty <span class="property-type">number</span>
196
+ </dt>
197
+ <dd>The presence penalty to use.</dd>
198
+
199
+ <dt>
200
+ frequency_penalty <span class="property-type">number</span>
201
+ </dt>
202
+ <dd>The frequency penalty to use.</dd>
203
+
204
+ <dt>
205
+ mirostat <span class="property-type">boolean</span>
206
+ </dt>
207
+ <dd>Use mirostat.</dd>
208
+
209
+ <dt>
210
+ mirostat_tau <span class="property-type">number</span>
211
+ </dt>
212
+
213
+ <dt>
214
+ mirostat_eta <span class="property-type">number</span>
215
+ </dt>
216
+
217
+ <dt>
218
+ penalize_newline <span class="property-type">boolean</span>
219
+ </dt>
220
+ <dd>Penalize newline.</dd>
221
+
222
+ <dt>
223
+ stop <span class="property-type">array</span>
224
+ </dt>
225
+ <dd>The stop to use.</dd>
226
+ </dl>
227
+ </dd>
268
228
  </dl>
269
229
  </dd>
270
230
  </dl>
@@ -7,16 +7,22 @@ module.exports = function( RED ) {
7
7
 
8
8
  node.on( 'input', async function( msg ) {
9
9
  const {
10
- host,
11
- model,
10
+ host: payloadHost,
11
+ model: payloadModel,
12
12
  input,
13
13
  truncate,
14
14
  keep_alive,
15
15
  options
16
16
  } = msg.payload
17
17
 
18
+ const server = RED.nodes.getNode( config.server )
19
+ const host = ( server ) ? server.host + ':' + server.port : payloadHost
20
+
18
21
  const ollama = new Ollama( { host } )
19
22
 
23
+ const modelConfig = RED.nodes.getNode( config.model )
24
+ const model = ( modelConfig ) ? modelConfig.name : payloadModel
25
+
20
26
  const response = await ollama.embed( {
21
27
  model,
22
28
  input,
@@ -3,7 +3,9 @@
3
3
  category: 'AI',
4
4
  color: 'rgb(186 230 253)',
5
5
  defaults: {
6
- name: { value: '' },
6
+ name: { value: 'Ollama Generate' },
7
+ server: { value: '', type: 'ollama-config-server', required: false },
8
+ model: { value: '', type: 'ollama-config-model', required: false },
7
9
  },
8
10
  inputs: 1,
9
11
  outputs: 1,
@@ -19,6 +21,16 @@
19
21
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
20
22
  <input type="text" id="node-input-name" placeholder="Name" />
21
23
  </div>
24
+
25
+ <div class="form-row">
26
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
27
+ <input type="text" id="node-input-server" />
28
+ </div>
29
+
30
+ <div class="form-row">
31
+ <label for="node-input-model"><i class="fa fa-bookmark"></i> Model</label>
32
+ <input type="text" id="node-input-model" />
33
+ </div>
22
34
  </script>
23
35
 
24
36
  <script type="text/html" data-help-name="ollama-generate">
@@ -27,94 +39,86 @@
27
39
  <h3>Inputs</h3>
28
40
 
29
41
  <dl class="message-properties">
30
- <dt>
31
- payload.host
32
-
33
- <span class="property-type">string</span>
34
- </dt>
35
- <dd>The host of the Ollama instance.</dd>
36
-
37
- <dt>
38
- payload.model
39
-
40
- <span class="property-type">string</span>
41
- </dt>
42
- <dd>The model to use for generating the next message.</dd>
43
-
44
- <dt>
45
- payload.prompt
46
-
47
- <span class="property-type">string</span>
48
- </dt>
49
- <dd>The prompt to generate a response for.</dd>
50
-
51
- <dt>
52
- payload.suffix
53
-
54
- <span class="property-type">string</span>
55
- </dt>
56
- <dd>The text after the model response.</dd>
57
-
58
42
  <dt class="optional">
59
- payload.images
60
-
61
- <span class="property-type">array</span>
43
+ payload <span class="property-type">object</span>
62
44
  </dt>
63
- <dd>A list of base64-encoded images (for multimodal models such as <code>llava</code>)</dd>
64
-
65
- <dt class="optional">
66
- payload.format
67
45
 
68
- <span class="property-type">string</span>
69
- </dt>
70
- <dd>The format to return a response in. Currently the only accepted value is <code>json</code></dd>
71
-
72
- <dt class="optional">
73
- payload.options
74
-
75
- <span class="property-type">object</span>
76
- </dt>
77
46
  <dd>
78
- Additional model parameters listed in the documentation for the <a href="https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values">Modelfile</a>.
47
+ The payload object.
48
+
49
+ <dl class="message-properties">
50
+ <dt class="optional">
51
+ payload.host <span class="property-type">string</span>
52
+ </dt>
53
+ <dd>
54
+ The host of the Ollama instance.<br />
55
+ <em>Alternative to the <code>Server</code> field.</em>
56
+ </dd>
57
+
58
+ <dt class="optional">
59
+ payload.model <span class="property-type">string</span>
60
+ </dt>
61
+ <dd>
62
+ The model to use for generating the next message.<br />
63
+ <em>Alternative to the <code>Model</code> field.</em>
64
+ </dd>
65
+
66
+ <dt>
67
+ payload.prompt <span class="property-type">string</span>
68
+ </dt>
69
+ <dd>The prompt to generate a response for.</dd>
70
+
71
+ <dt>
72
+ payload.suffix <span class="property-type">string</span>
73
+ </dt>
74
+ <dd>The text after the model response.</dd>
75
+
76
+ <dt class="optional">
77
+ payload.images <span class="property-type">array</span>
78
+ </dt>
79
+ <dd>A list of base64-encoded images (for multimodal models such as <code>llava</code>)</dd>
80
+
81
+ <dt class="optional">
82
+ payload.format <span class="property-type">string</span>
83
+ </dt>
84
+ <dd>The format to return a response in. Currently the only accepted value is <code>json</code></dd>
85
+
86
+ <dt class="optional">
87
+ payload.options <span class="property-type">object</span>
88
+ </dt>
89
+ <dd>
90
+ Additional model parameters listed in the documentation for the <a href="https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values">Modelfile</a>.
91
+ </dd>
92
+
93
+ <dt class="optional">
94
+ payload.system <span class="property-type">string</span>
95
+ </dt>
96
+ <dd>System message to (overrides what is defined in the <code>Modelfile</code>)</dd>
97
+
98
+ <dt class="optional">
99
+ payload.template <span class="property-type">string</span>
100
+ </dt>
101
+ <dd>The prompt template to use (overrides what is defined in the <code>Modelfile</code>)</dd>
102
+
103
+ <dt class="optional">
104
+ payload.stream <span class="property-type">boolean</span>
105
+ </dt>
106
+ <dd>If <code>false</code> the response will be returned as a single response object, rather than a stream of objects.</dd>
107
+
108
+ <dt class="optional">
109
+ payload.raw <span class="property-type">boolean</span>
110
+ </dt>
111
+ <dd>
112
+ If <code>true</code> no formatting will be applied to the prompt.<br />
113
+ You may choose to use the <code>raw</code> parameter if you are specifying a full templated prompt in your request to the API.
114
+ </dd>
115
+
116
+ <dt class="optional">
117
+ payload.keep_alive <span class="property-type">string | number</span>
118
+ </dt>
119
+ <dd>Controls how long the model will stay loaded into memory following the request (default: <code>5m</code>)</dd>
120
+ </dl>
79
121
  </dd>
80
-
81
- <dt class="optional">
82
- payload.system
83
-
84
- <span class="property-type">string</span>
85
- </dt>
86
- <dd>System message to (overrides what is defined in the <code>Modelfile</code>)</dd>
87
-
88
- <dt class="optional">
89
- payload.template
90
-
91
- <span class="property-type">string</span>
92
- </dt>
93
- <dd>The prompt template to use (overrides what is defined in the <code>Modelfile</code>)</dd>
94
-
95
- <dt class="optional">
96
- payload.stream
97
-
98
- <span class="property-type">boolean</span>
99
- </dt>
100
- <dd>If <code>false</code> the response will be returned as a single response object, rather than a stream of objects.</dd>
101
-
102
- <dt class="optional">
103
- payload.raw
104
-
105
- <span class="property-type">boolean</span>
106
- </dt>
107
- <dd>
108
- If <code>true</code> no formatting will be applied to the prompt.<br />
109
- You may choose to use the <code>raw</code> parameter if you are specifying a full templated prompt in your request to the API.
110
- </dd>
111
-
112
- <dt class="optional">
113
- payload.keep_alive
114
-
115
- <span class="property-type">string | number</span>
116
- </dt>
117
- <dd>Controls how long the model will stay loaded into memory following the request (default: <code>5m</code>)</dd>
118
122
  </dl>
119
123
 
120
124
  <h3>Outputs</h3>