node-red-contrib-ollama 0.2.4 → 0.2.6

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.
@@ -6,7 +6,9 @@
6
6
  name: { value: 'Ollama Chat' },
7
7
  server: { value: '', type: 'ollama-config-server', required: false },
8
8
  model: { value: '', type: 'ollama-config-model', required: true },
9
+ format: { value: '', type: 'ollama-config-format', required: false },
9
10
  tools: { value: '', type: 'ollama-config-tools', required: false },
11
+ options: { value: '', type: 'ollama-config-options', required: false },
10
12
  },
11
13
  inputs: 1,
12
14
  outputs: 1,
@@ -33,10 +35,20 @@
33
35
  <input type="text" id="node-input-model" />
34
36
  </div>
35
37
 
38
+ <div class="form-row">
39
+ <label for="node-input-format"><i class="fa fa-cog"></i> Format</label>
40
+ <input type="text" id="node-input-format" />
41
+ </div>
42
+
36
43
  <div class="form-row">
37
44
  <label for="node-input-tools"><i class="fa fa-cog"></i> Tools</label>
38
45
  <input type="text" id="node-input-tools" />
39
46
  </div>
47
+
48
+ <div class="form-row">
49
+ <label for="node-input-options"><i class="fa fa-cog"></i> Options</label>
50
+ <input type="text" id="node-input-options" />
51
+ </div>
40
52
  </script>
41
53
 
42
54
  <script type="text/html" data-help-name="ollama-chat">
@@ -102,7 +114,10 @@
102
114
  <dt class="optional">
103
115
  payload.format <span class="property-type">string</span>
104
116
  </dt>
105
- <dd>The format of the response (only <code>json</code> for now).</dd>
117
+ <dd>
118
+ The format of the response (only <code>json</code> for now).<br />
119
+ <em>Alternative to the <code>Format</code> field.</em>
120
+ </dd>
106
121
 
107
122
  <dt class="optional">
108
123
  payload.stream <span class="property-type">boolean</span>
@@ -119,7 +134,7 @@
119
134
  </dt>
120
135
  <dd>
121
136
  Tools for the model to use if supported.<br />
122
- Requires <code>stream</code> to be set to <code>false</code>.
137
+ Requires <code>stream</code> to be set to <code>false</code>.<br />
123
138
  <em>Alternative to the <code>Model</code> field.</em>
124
139
 
125
140
  <p>
@@ -133,6 +148,7 @@
133
148
  </dt>
134
149
  <dd>
135
150
  Options to configure the runtime.<br />
151
+ <em>Alternative to the <code>Options</code> field.</em>
136
152
 
137
153
  <h4>Options</h4>
138
154
  <dl class="message-properties">
@@ -10,11 +10,11 @@ module.exports = function( RED ) {
10
10
  host: payloadHost,
11
11
  model: payloadModel,
12
12
  messages,
13
- format,
13
+ format: payloadFormat,
14
14
  stream,
15
15
  keep_alive,
16
16
  tools: payloadTools,
17
- options
17
+ options: payloadOptions
18
18
  } = msg.payload
19
19
 
20
20
  const server = RED.nodes.getNode( config.server )
@@ -25,9 +25,15 @@ module.exports = function( RED ) {
25
25
  const modelConfig = RED.nodes.getNode( config.model )
26
26
  const model = ( modelConfig ) ? modelConfig.name : payloadModel
27
27
 
28
+ const formatConfig = RED.nodes.getNode( config.format )
29
+ const format = ( formatConfig ) ? formatConfig.json : payloadFormat
30
+
28
31
  const toolsConfig = RED.nodes.getNode( config.tools )
29
32
  const tools = ( toolsConfig ) ? toolsConfig.json : payloadTools
30
33
 
34
+ const optionsConfig = RED.nodes.getNode( config.options )
35
+ const options = ( optionsConfig ) ? optionsConfig.json : payloadOptions
36
+
31
37
  const response = await ollama.chat( {
32
38
  model,
33
39
  messages,
@@ -0,0 +1,30 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType( 'ollama-config-format', {
3
+ category: 'config',
4
+ defaults: {
5
+ name: { value: 'Ollama Format Config' },
6
+ json: { value: '' }
7
+ },
8
+ label: function() {
9
+ return this.name;
10
+ },
11
+ oneditprepare: function() {
12
+ $( '#node-config-input-json' ).typedInput( {
13
+ type: 'json',
14
+ types: [ 'json' ]
15
+ } )
16
+ }
17
+ } )
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="ollama-config-format">
21
+ <div class="form-row">
22
+ <label for="node-config-input-name"><i class="fa fa-server"></i> Name</label>
23
+ <input type="text" id="node-config-input-name" placeholder="Ollama Format Config" />
24
+ </div>
25
+
26
+ <div class="form-row">
27
+ <label for="node-config-input-json"><i class="fa fa-cog"></i> JSON</label>
28
+ <input type="text" id="node-config-input-json" placeholder="" />
29
+ </div>
30
+ </script>
@@ -0,0 +1,10 @@
1
+ module.exports = function( RED ) {
2
+ function OllamaConfigFormatNode( config ) {
3
+ RED.nodes.createNode( this, config )
4
+
5
+ this.name = config.name
6
+ this.json = config.json
7
+ }
8
+
9
+ RED.nodes.registerType( 'ollama-config-format', OllamaConfigFormatNode )
10
+ }
@@ -0,0 +1,25 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType( 'ollama-config-options', {
3
+ category: 'config',
4
+ defaults: {
5
+ name: { value: 'Ollama Options Config' },
6
+ json: { value: '' }
7
+ },
8
+ label: function() {
9
+ return this.name;
10
+ },
11
+ oneditprepare: function() {
12
+ $( '#node-config-input-json' ).typedInput( {
13
+ type: 'json',
14
+ types: [ 'json' ]
15
+ } )
16
+ }
17
+ } )
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="ollama-config-options">
21
+ <div class="form-row">
22
+ <label for="node-config-input-json"><i class="fa fa-server"></i> JSON</label>
23
+ <input type="text" id="node-config-input-json" />
24
+ </div>
25
+ </script>
@@ -0,0 +1,10 @@
1
+ module.exports = function( RED ) {
2
+ function OllamaConfigOptionsNode( config ) {
3
+ RED.nodes.createNode( this, config )
4
+
5
+ this.name = config.name
6
+ this.json = config.json
7
+ }
8
+
9
+ RED.nodes.registerType( 'ollama-config-options', OllamaConfigOptionsNode )
10
+ }
@@ -6,6 +6,7 @@
6
6
  name: { value: 'Ollama Embed' },
7
7
  server: { value: '', type: 'ollama-config-server', required: false },
8
8
  model: { value: '', type: 'ollama-config-model', required: false },
9
+ options: { value: '', type: 'ollama-config-options', required: false },
9
10
  },
10
11
  inputs: 1,
11
12
  outputs: 1,
@@ -31,6 +32,11 @@
31
32
  <label for="node-input-model"><i class="fa fa-bookmark"></i> Model</label>
32
33
  <input type="text" id="node-input-model" />
33
34
  </div>
35
+
36
+ <div class="form-row">
37
+ <label for="node-input-options"><i class="fa fa-cog"></i> Options</label>
38
+ <input type="text" id="node-input-options" />
39
+ </div>
34
40
  </script>
35
41
 
36
42
  <script type="text/html" data-help-name="ollama-embed">
@@ -83,6 +89,7 @@
83
89
  </dt>
84
90
  <dd>
85
91
  Options to configure the runtime.<br />
92
+ <em>Alternative to the <code>Options</code> field.</em>
86
93
 
87
94
  <h4>Options</h4>
88
95
  <dl class="message-properties">
@@ -12,7 +12,7 @@ module.exports = function( RED ) {
12
12
  input,
13
13
  truncate,
14
14
  keep_alive,
15
- options
15
+ options: payloadOptions
16
16
  } = msg.payload
17
17
 
18
18
  const server = RED.nodes.getNode( config.server )
@@ -23,6 +23,9 @@ module.exports = function( RED ) {
23
23
  const modelConfig = RED.nodes.getNode( config.model )
24
24
  const model = ( modelConfig ) ? modelConfig.name : payloadModel
25
25
 
26
+ const optionsConfig = RED.nodes.getNode( config.options )
27
+ const options = ( optionsConfig ) ? optionsConfig.json : payloadOptions
28
+
26
29
  const response = await ollama.embed( {
27
30
  model,
28
31
  input,
@@ -5,7 +5,9 @@
5
5
  defaults: {
6
6
  name: { value: 'Ollama Generate' },
7
7
  server: { value: '', type: 'ollama-config-server', required: false },
8
+ format: { value: '', type: 'ollama-config-format', required: false },
8
9
  model: { value: '', type: 'ollama-config-model', required: false },
10
+ options: { value: '', type: 'ollama-config-options', required: false },
9
11
  },
10
12
  inputs: 1,
11
13
  outputs: 1,
@@ -27,10 +29,20 @@
27
29
  <input type="text" id="node-input-server" />
28
30
  </div>
29
31
 
32
+ <div class="form-row">
33
+ <label for="node-input-format"><i class="fa fa-cog"></i> Format</label>
34
+ <input type="text" id="node-input-format" />
35
+ </div>
36
+
30
37
  <div class="form-row">
31
38
  <label for="node-input-model"><i class="fa fa-bookmark"></i> Model</label>
32
39
  <input type="text" id="node-input-model" />
33
40
  </div>
41
+
42
+ <div class="form-row">
43
+ <label for="node-input-options"><i class="fa fa-cog"></i> Options</label>
44
+ <input type="text" id="node-input-options" />
45
+ </div>
34
46
  </script>
35
47
 
36
48
  <script type="text/html" data-help-name="ollama-generate">
@@ -81,13 +93,17 @@
81
93
  <dt class="optional">
82
94
  payload.format <span class="property-type">string</span>
83
95
  </dt>
84
- <dd>The format to return a response in. Currently the only accepted value is <code>json</code></dd>
96
+ <dd>
97
+ The format to return a response in. Currently the only accepted value is <code>json</code><br />
98
+ <em>Alternative to the <code>Format</code> field.</em>
99
+ </dd>
85
100
 
86
101
  <dt class="optional">
87
102
  payload.options <span class="property-type">object</span>
88
103
  </dt>
89
104
  <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>.
105
+ 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>.<br />
106
+ <em>Alternative to the <code>Options</code> field.</em>
91
107
  </dd>
92
108
 
93
109
  <dt class="optional">
@@ -15,10 +15,10 @@ module.exports = function( RED ) {
15
15
  template,
16
16
  raw,
17
17
  images,
18
- format,
18
+ format: payloadFormat,
19
19
  stream,
20
20
  keep_alive,
21
- options
21
+ options: payloadOptions
22
22
  } = msg.payload
23
23
 
24
24
  const server = RED.nodes.getNode( config.server )
@@ -29,6 +29,12 @@ module.exports = function( RED ) {
29
29
  const modelConfig = RED.nodes.getNode( config.model )
30
30
  const model = ( modelConfig ) ? modelConfig.name : payloadModel
31
31
 
32
+ const formatConfig = RED.nodes.getNode( config.format )
33
+ const format = ( formatConfig ) ? formatConfig.json : payloadFormat
34
+
35
+ const optionsConfig = RED.nodes.getNode( config.options )
36
+ const options = ( optionsConfig ) ? optionsConfig.json : payloadOptions
37
+
32
38
  const response = await ollama.generate( {
33
39
  model,
34
40
  prompt,
@@ -6,6 +6,7 @@
6
6
  name: { value: 'Ollama Show' },
7
7
  server: { value: '', type: 'ollama-config-server', required: false },
8
8
  model: { value: '', type: 'ollama-config-model', required: false },
9
+ options: { value: '', type: 'ollama-config-options', required: false },
9
10
  },
10
11
  inputs: 1,
11
12
  outputs: 1,
@@ -31,6 +32,11 @@
31
32
  <label for="node-input-model"><i class="fa fa-bookmark"></i> Model</label>
32
33
  <input type="text" id="node-input-model" />
33
34
  </div>
35
+
36
+ <div class="form-row">
37
+ <label for="node-input-options"><i class="fa fa-cog"></i> Options</label>
38
+ <input type="text" id="node-input-options" />
39
+ </div>
34
40
  </script>
35
41
 
36
42
  <script type="text/html" data-help-name="ollama-show">
@@ -75,7 +81,10 @@
75
81
  <dt class="optional">
76
82
  payload.options <span class="property-type">object</span>
77
83
  </dt>
78
- <dd>Options to configure the runtime.</dd>
84
+ <dd>
85
+ Options to configure the runtime.<br />
86
+ <em>Alternative to the <code>Server</code> field.</em>
87
+ </dd>
79
88
  </dl>
80
89
  </dd>
81
90
  </dl>
@@ -11,7 +11,7 @@ module.exports = function( RED ) {
11
11
  model: payloadModel,
12
12
  system,
13
13
  template,
14
- options
14
+ options: payloadOptions
15
15
  } = msg.payload
16
16
 
17
17
  const server = RED.nodes.getNode( config.server )
@@ -22,6 +22,9 @@ module.exports = function( RED ) {
22
22
  const modelConfig = RED.nodes.getNode( config.model )
23
23
  const model = ( modelConfig ) ? modelConfig.name : payloadModel
24
24
 
25
+ const optionsConfig = RED.nodes.getNode( config.options )
26
+ const options = ( optionsConfig ) ? optionsConfig.json : payloadOptions
27
+
25
28
  const response = await ollama.show( {
26
29
  model,
27
30
  system,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-ollama",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Add AI functionality to your flows! This module includes a set of nodes that enable easy communication with Ollama, enriching your projects with intelligent solutions.",
5
5
  "keywords": [
6
6
  "ai",
@@ -31,7 +31,9 @@
31
31
  "ollama-abort": "nodes/ollama-abort.js",
32
32
  "ollama-config-server": "nodes/ollama-config-server.js",
33
33
  "ollama-config-model": "nodes/ollama-config-model.js",
34
- "ollama-config-tools": "nodes/ollama-config-tools.js"
34
+ "ollama-config-format": "nodes/ollama-config-format.js",
35
+ "ollama-config-tools": "nodes/ollama-config-tools.js",
36
+ "ollama-config-options": "nodes/ollama-config-options.js"
35
37
  }
36
38
  },
37
39
  "engines": {