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