node-red-contrib-ollama 0.2.3 → 0.2.5
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/nodes/ollama-chat.html +18 -2
- package/nodes/ollama-chat.js +8 -2
- package/nodes/ollama-config-format.html +30 -0
- package/nodes/ollama-config-format.js +10 -0
- package/nodes/ollama-config-tools.html +30 -0
- package/nodes/ollama-config-tools.js +10 -0
- package/nodes/ollama-generate.html +10 -1
- package/nodes/ollama-generate.js +4 -1
- package/package.json +4 -2
package/nodes/ollama-chat.html
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
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 },
|
|
10
|
+
tools: { value: '', type: 'ollama-config-tools', required: false },
|
|
9
11
|
},
|
|
10
12
|
inputs: 1,
|
|
11
13
|
outputs: 1,
|
|
@@ -31,6 +33,16 @@
|
|
|
31
33
|
<label for="node-input-model"><i class="fa fa-bookmark"></i> Model</label>
|
|
32
34
|
<input type="text" id="node-input-model" />
|
|
33
35
|
</div>
|
|
36
|
+
|
|
37
|
+
<div class="form-row">
|
|
38
|
+
<label for="node-input-format"><i class="fa fa-cog"></i> Format</label>
|
|
39
|
+
<input type="text" id="node-input-format" />
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="form-row">
|
|
43
|
+
<label for="node-input-tools"><i class="fa fa-cog"></i> Tools</label>
|
|
44
|
+
<input type="text" id="node-input-tools" />
|
|
45
|
+
</div>
|
|
34
46
|
</script>
|
|
35
47
|
|
|
36
48
|
<script type="text/html" data-help-name="ollama-chat">
|
|
@@ -96,7 +108,10 @@
|
|
|
96
108
|
<dt class="optional">
|
|
97
109
|
payload.format <span class="property-type">string</span>
|
|
98
110
|
</dt>
|
|
99
|
-
<dd>
|
|
111
|
+
<dd>
|
|
112
|
+
The format of the response (only <code>json</code> for now).<br />
|
|
113
|
+
<em>Alternative to the <code>Format</code> field.</em>
|
|
114
|
+
</dd>
|
|
100
115
|
|
|
101
116
|
<dt class="optional">
|
|
102
117
|
payload.stream <span class="property-type">boolean</span>
|
|
@@ -113,7 +128,8 @@
|
|
|
113
128
|
</dt>
|
|
114
129
|
<dd>
|
|
115
130
|
Tools for the model to use if supported.<br />
|
|
116
|
-
Requires <code>stream</code> to be set to <code>false</code
|
|
131
|
+
Requires <code>stream</code> to be set to <code>false</code>.<br />
|
|
132
|
+
<em>Alternative to the <code>Model</code> field.</em>
|
|
117
133
|
|
|
118
134
|
<p>
|
|
119
135
|
For more information, see the Ollama API documentation:<br />
|
package/nodes/ollama-chat.js
CHANGED
|
@@ -10,10 +10,10 @@ 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
|
-
tools,
|
|
16
|
+
tools: payloadTools,
|
|
17
17
|
options
|
|
18
18
|
} = msg.payload
|
|
19
19
|
|
|
@@ -25,6 +25,12 @@ 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
|
+
|
|
31
|
+
const toolsConfig = RED.nodes.getNode( config.tools )
|
|
32
|
+
const tools = ( toolsConfig ) ? toolsConfig.json : payloadTools
|
|
33
|
+
|
|
28
34
|
const response = await ollama.chat( {
|
|
29
35
|
model,
|
|
30
36
|
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,30 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType( 'ollama-config-tools', {
|
|
3
|
+
category: 'config',
|
|
4
|
+
defaults: {
|
|
5
|
+
name: { value: 'Ollama Tools 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-tools">
|
|
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 Tools 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>
|
|
@@ -5,6 +5,7 @@
|
|
|
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 },
|
|
9
10
|
},
|
|
10
11
|
inputs: 1,
|
|
@@ -27,6 +28,11 @@
|
|
|
27
28
|
<input type="text" id="node-input-server" />
|
|
28
29
|
</div>
|
|
29
30
|
|
|
31
|
+
<div class="form-row">
|
|
32
|
+
<label for="node-input-format"><i class="fa fa-cog"></i> Format</label>
|
|
33
|
+
<input type="text" id="node-input-format" />
|
|
34
|
+
</div>
|
|
35
|
+
|
|
30
36
|
<div class="form-row">
|
|
31
37
|
<label for="node-input-model"><i class="fa fa-bookmark"></i> Model</label>
|
|
32
38
|
<input type="text" id="node-input-model" />
|
|
@@ -81,7 +87,10 @@
|
|
|
81
87
|
<dt class="optional">
|
|
82
88
|
payload.format <span class="property-type">string</span>
|
|
83
89
|
</dt>
|
|
84
|
-
<dd>
|
|
90
|
+
<dd>
|
|
91
|
+
The format to return a response in. Currently the only accepted value is <code>json</code><br />
|
|
92
|
+
<em>Alternative to the <code>Format</code> field.</em>
|
|
93
|
+
</dd>
|
|
85
94
|
|
|
86
95
|
<dt class="optional">
|
|
87
96
|
payload.options <span class="property-type">object</span>
|
package/nodes/ollama-generate.js
CHANGED
|
@@ -15,7 +15,7 @@ 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
21
|
options
|
|
@@ -29,6 +29,9 @@ 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
|
+
|
|
32
35
|
const response = await ollama.generate( {
|
|
33
36
|
model,
|
|
34
37
|
prompt,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-ollama",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
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",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"ollama-ps": "nodes/ollama-ps.js",
|
|
31
31
|
"ollama-abort": "nodes/ollama-abort.js",
|
|
32
32
|
"ollama-config-server": "nodes/ollama-config-server.js",
|
|
33
|
-
"ollama-config-model": "nodes/ollama-config-model.js"
|
|
33
|
+
"ollama-config-model": "nodes/ollama-config-model.js",
|
|
34
|
+
"ollama-config-format": "nodes/ollama-config-format.js",
|
|
35
|
+
"ollama-config-tools": "nodes/ollama-config-tools.js"
|
|
34
36
|
}
|
|
35
37
|
},
|
|
36
38
|
"engines": {
|