node-red-contrib-ollama 0.1.9 → 0.2.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 +0 -0
- package/README.md +6 -2
- package/examples/Example.json +0 -0
- package/node-red-contrib-ollama-logo.png +0 -0
- package/nodes/ollama-abort.html +37 -0
- package/nodes/{ollama-embeddings.js → ollama-abort.js} +4 -4
- package/nodes/ollama-chat.html +23 -1
- package/nodes/ollama-chat.js +19 -2
- package/nodes/ollama-copy.html +0 -0
- package/nodes/ollama-copy.js +0 -0
- package/nodes/ollama-create.html +0 -21
- package/nodes/ollama-create.js +16 -5
- package/nodes/ollama-delete.html +0 -0
- package/nodes/ollama-delete.js +0 -0
- package/nodes/{ollama-embeddings.html → ollama-embed.html} +21 -9
- package/nodes/ollama-embed.js +37 -0
- package/nodes/ollama-generate.html +30 -217
- package/nodes/ollama-generate.js +30 -5
- package/nodes/ollama-list.html +0 -7
- package/nodes/ollama-list.js +0 -0
- package/nodes/ollama-ps.html +136 -0
- package/nodes/ollama-ps.js +24 -0
- package/nodes/ollama-pull.html +0 -0
- package/nodes/ollama-pull.js +0 -0
- package/nodes/ollama-push.html +0 -0
- package/nodes/ollama-push.js +0 -0
- package/nodes/ollama-show.html +0 -0
- package/nodes/ollama-show.js +16 -5
- package/package.json +6 -4
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -10,9 +10,11 @@ A Node-RED module that wraps the [ollama.js](https://github.com/ollama/ollama-js
|
|
|
10
10
|
|
|
11
11
|
## Requirements
|
|
12
12
|
|
|
13
|
+
This module requires Node.js version 18 or higher.
|
|
14
|
+
|
|
13
15
|
To use it, you need to have Node-RED installed on your system. For more information on how to install Node-RED, refer to the official [Node-RED documentation](https://nodered.org/docs/getting-started/).
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
You also need Ollama running on the same or a different system. For detailed instructions on how to install Ollama, please refer to the official [Ollama site](https://ollama.com/).
|
|
16
18
|
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
@@ -46,12 +48,14 @@ The module provides a set of nodes that can be used to interact with the ollama.
|
|
|
46
48
|
- **Copy**: Copy a model. Creates a model with another name from an existing model.
|
|
47
49
|
- **Create**: Create a model from a [Modelfile](https://github.com/ollama/ollama/blob/main/docs/modelfile.md).
|
|
48
50
|
- **Delete**: Delete a model and its data.
|
|
49
|
-
- **
|
|
51
|
+
- **Embed**: Generate embeddings from a model.
|
|
50
52
|
- **Generate**: Generate a response for a given prompt with a provided model.
|
|
51
53
|
- **List**: List models that are available locally.
|
|
52
54
|
- **Pull**: Download a model from the [ollama library](https://ollama.com/library).
|
|
53
55
|
- **Push**: Upload a model to a model library. Requires registering for ollama.ai and adding a public key first.
|
|
54
56
|
- **Show**: Show information about a model including details, modelfile, template, parameters, license, and system prompt.
|
|
57
|
+
- **Ps**: List models that are currently loaded into memory.
|
|
58
|
+
- **Abort**: This method will abort all streamed generations currently running.
|
|
55
59
|
|
|
56
60
|
Each node has its own set of configuration options that can be used to customize its behavior. For more information on how to use each node, refer to the help text provided in the Node-RED editor.
|
|
57
61
|
|
package/examples/Example.json
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType( 'ollama-abort', {
|
|
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-abort';
|
|
13
|
+
},
|
|
14
|
+
} )
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="ollama-abort">
|
|
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-abort">
|
|
25
|
+
<p>This method will abort all streamed generations currently running. All asynchronous threads listening to streams (typically the for await (const part of response)) will throw an AbortError exception.</p>
|
|
26
|
+
|
|
27
|
+
<h3>Inputs</h3>
|
|
28
|
+
|
|
29
|
+
<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
|
+
</dl>
|
|
37
|
+
</script>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
module.exports = function( RED ) {
|
|
2
2
|
const { Ollama } = require( 'ollama' )
|
|
3
3
|
|
|
4
|
-
function
|
|
4
|
+
function OllamaAbortNode( config ) {
|
|
5
5
|
RED.nodes.createNode( this, config )
|
|
6
6
|
const node = this
|
|
7
7
|
|
|
8
8
|
node.on( 'input', async function( msg ) {
|
|
9
|
-
const { host
|
|
9
|
+
const { host } = msg.payload
|
|
10
10
|
|
|
11
11
|
const ollama = new Ollama( { host } )
|
|
12
12
|
|
|
13
|
-
const response = await ollama.
|
|
13
|
+
const response = await ollama.abort()
|
|
14
14
|
.catch( error => {
|
|
15
15
|
node.error( error )
|
|
16
16
|
} )
|
|
@@ -20,5 +20,5 @@ module.exports = function( RED ) {
|
|
|
20
20
|
} )
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
RED.nodes.registerType( 'ollama-
|
|
23
|
+
RED.nodes.registerType( 'ollama-abort', OllamaAbortNode )
|
|
24
24
|
}
|
package/nodes/ollama-chat.html
CHANGED
|
@@ -71,6 +71,13 @@
|
|
|
71
71
|
<span class="property-type">array</span>
|
|
72
72
|
</dt>
|
|
73
73
|
<dd>The images attached to the message, either as Uint8Array or base64 encoded strings.</dd>
|
|
74
|
+
|
|
75
|
+
<dt>
|
|
76
|
+
tool_calls
|
|
77
|
+
|
|
78
|
+
<span class="property-type">array</span>
|
|
79
|
+
</dt>
|
|
80
|
+
<dd>A list of tools the model wants to use.</dd>
|
|
74
81
|
</dl>
|
|
75
82
|
</dd>
|
|
76
83
|
|
|
@@ -91,10 +98,25 @@
|
|
|
91
98
|
<dt class="optional">
|
|
92
99
|
payload.keep_alive
|
|
93
100
|
|
|
94
|
-
<span class="property-type">
|
|
101
|
+
<span class="property-type">array</span>
|
|
95
102
|
</dt>
|
|
96
103
|
<dd>How long to keep the model loaded.</dd>
|
|
97
104
|
|
|
105
|
+
<dt class="optional">
|
|
106
|
+
payload.tools
|
|
107
|
+
|
|
108
|
+
<span class="property-type">array</span>
|
|
109
|
+
</dt>
|
|
110
|
+
<dd>
|
|
111
|
+
Tools for the model to use if supported.<br />
|
|
112
|
+
Requires <code>stream</code> to be set to <code>false</code>.
|
|
113
|
+
|
|
114
|
+
<p>
|
|
115
|
+
For more information, see the Ollama API documentation:<br />
|
|
116
|
+
<a href="https://github.com/ollama/ollama/blob/main/docs/api.md#chat-request-with-tools" target="_blank">Chat request with tools</a>
|
|
117
|
+
</p>
|
|
118
|
+
</dd>
|
|
119
|
+
|
|
98
120
|
<dt class="optional">
|
|
99
121
|
payload.options
|
|
100
122
|
|
package/nodes/ollama-chat.js
CHANGED
|
@@ -6,11 +6,28 @@ module.exports = function( RED ) {
|
|
|
6
6
|
const node = this
|
|
7
7
|
|
|
8
8
|
node.on( 'input', async function( msg ) {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
host,
|
|
11
|
+
model,
|
|
12
|
+
messages,
|
|
13
|
+
format,
|
|
14
|
+
stream,
|
|
15
|
+
keep_alive,
|
|
16
|
+
tools,
|
|
17
|
+
options
|
|
18
|
+
} = msg.payload
|
|
10
19
|
|
|
11
20
|
const ollama = new Ollama( { host } )
|
|
12
21
|
|
|
13
|
-
const response = await ollama.chat( {
|
|
22
|
+
const response = await ollama.chat( {
|
|
23
|
+
model,
|
|
24
|
+
messages,
|
|
25
|
+
format,
|
|
26
|
+
stream,
|
|
27
|
+
keep_alive,
|
|
28
|
+
tools,
|
|
29
|
+
options
|
|
30
|
+
} )
|
|
14
31
|
.catch( error => {
|
|
15
32
|
node.error( error )
|
|
16
33
|
} )
|
package/nodes/ollama-copy.html
CHANGED
|
File without changes
|
package/nodes/ollama-copy.js
CHANGED
|
File without changes
|
package/nodes/ollama-create.html
CHANGED
|
@@ -72,26 +72,5 @@
|
|
|
72
72
|
<span class="property-type">string</span>
|
|
73
73
|
</dt>
|
|
74
74
|
<dd>The progress status.</dd>
|
|
75
|
-
|
|
76
|
-
<dt>
|
|
77
|
-
payload.digest
|
|
78
|
-
|
|
79
|
-
<span class="property-type">string</span>
|
|
80
|
-
</dt>
|
|
81
|
-
<dd>The progress digest.</dd>
|
|
82
|
-
|
|
83
|
-
<dt>
|
|
84
|
-
payload.total
|
|
85
|
-
|
|
86
|
-
<span class="property-type">number</span>
|
|
87
|
-
</dt>
|
|
88
|
-
<dd>The total progress.</dd>
|
|
89
|
-
|
|
90
|
-
<dt>
|
|
91
|
-
payload.completed
|
|
92
|
-
|
|
93
|
-
<span class="property-type">number</span>
|
|
94
|
-
</dt>
|
|
95
|
-
<dd>The completed progress.</dd>
|
|
96
75
|
</dl>
|
|
97
76
|
</script>
|
package/nodes/ollama-create.js
CHANGED
|
@@ -6,14 +6,25 @@ module.exports = function( RED ) {
|
|
|
6
6
|
const node = this
|
|
7
7
|
|
|
8
8
|
node.on( 'input', async function( msg ) {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
host,
|
|
11
|
+
model,
|
|
12
|
+
modelfile,
|
|
13
|
+
stream,
|
|
14
|
+
path
|
|
15
|
+
} = msg.payload
|
|
10
16
|
|
|
11
17
|
const ollama = new Ollama( { host } )
|
|
12
18
|
|
|
13
|
-
const response = await ollama.create( {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
const response = await ollama.create( {
|
|
20
|
+
model,
|
|
21
|
+
modelfile,
|
|
22
|
+
stream,
|
|
23
|
+
path
|
|
24
|
+
} )
|
|
25
|
+
.catch( error => {
|
|
26
|
+
node.error( error )
|
|
27
|
+
} )
|
|
17
28
|
|
|
18
29
|
msg.payload = response
|
|
19
30
|
node.send( msg )
|
package/nodes/ollama-delete.html
CHANGED
|
File without changes
|
package/nodes/ollama-delete.js
CHANGED
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType( 'ollama-
|
|
2
|
+
RED.nodes.registerType( 'ollama-embed', {
|
|
3
3
|
category: 'AI',
|
|
4
4
|
color: 'rgb(186 230 253)',
|
|
5
5
|
defaults: {
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
outputs: 1,
|
|
10
10
|
icon: 'ollama.png',
|
|
11
11
|
label: function() {
|
|
12
|
-
return this.name || 'ollama-
|
|
12
|
+
return this.name || 'ollama-embed';
|
|
13
13
|
},
|
|
14
14
|
} )
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
|
-
<script type="text/html" data-template-name="ollama-
|
|
17
|
+
<script type="text/html" data-template-name="ollama-embed">
|
|
18
18
|
<div class="form-row">
|
|
19
19
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
20
|
<input type="text" id="node-input-name" placeholder="Name" />
|
|
21
21
|
</div>
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
|
-
<script type="text/html" data-help-name="ollama-
|
|
24
|
+
<script type="text/html" data-help-name="ollama-embed">
|
|
25
25
|
<p>Generate embeddings from a model</p>
|
|
26
26
|
|
|
27
27
|
<h3>Inputs</h3>
|
|
@@ -39,14 +39,21 @@
|
|
|
39
39
|
|
|
40
40
|
<span class="property-type">string</span>
|
|
41
41
|
</dt>
|
|
42
|
-
<dd>The model to
|
|
42
|
+
<dd>The name of the model used to generate the embeddings.</dd>
|
|
43
43
|
|
|
44
44
|
<dt>
|
|
45
|
-
payload.
|
|
45
|
+
payload.input
|
|
46
46
|
|
|
47
|
-
<span class="property-type">string</span>
|
|
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>
|
|
48
55
|
</dt>
|
|
49
|
-
<dd>
|
|
56
|
+
<dd>Truncate the input to fit the maximum context length supported by the model.</dd>
|
|
50
57
|
|
|
51
58
|
<dt class="optional">
|
|
52
59
|
payload.keep_alive
|
|
@@ -266,7 +273,12 @@
|
|
|
266
273
|
|
|
267
274
|
<dl class="message-properties">
|
|
268
275
|
<dt>
|
|
269
|
-
payload.
|
|
276
|
+
payload.model
|
|
277
|
+
</dt>
|
|
278
|
+
<dd>Name of the model.</dd>
|
|
279
|
+
|
|
280
|
+
<dt>
|
|
281
|
+
payload.embeddings
|
|
270
282
|
|
|
271
283
|
<span class="property-type">array</span>
|
|
272
284
|
</dt>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module.exports = function( RED ) {
|
|
2
|
+
const { Ollama } = require( 'ollama' )
|
|
3
|
+
|
|
4
|
+
function OllamaEmbedNode( config ) {
|
|
5
|
+
RED.nodes.createNode( this, config )
|
|
6
|
+
const node = this
|
|
7
|
+
|
|
8
|
+
node.on( 'input', async function( msg ) {
|
|
9
|
+
const {
|
|
10
|
+
host,
|
|
11
|
+
model,
|
|
12
|
+
input,
|
|
13
|
+
truncate,
|
|
14
|
+
keep_alive,
|
|
15
|
+
options
|
|
16
|
+
} = msg.payload
|
|
17
|
+
|
|
18
|
+
const ollama = new Ollama( { host } )
|
|
19
|
+
|
|
20
|
+
const response = await ollama.embed( {
|
|
21
|
+
model,
|
|
22
|
+
input,
|
|
23
|
+
truncate,
|
|
24
|
+
keep_alive,
|
|
25
|
+
options
|
|
26
|
+
} )
|
|
27
|
+
.catch( error => {
|
|
28
|
+
node.error( error )
|
|
29
|
+
} )
|
|
30
|
+
|
|
31
|
+
msg.payload = response
|
|
32
|
+
node.send( msg )
|
|
33
|
+
} )
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
RED.nodes.registerType( 'ollama-embed', OllamaEmbedNode )
|
|
37
|
+
}
|
|
@@ -48,260 +48,73 @@
|
|
|
48
48
|
</dt>
|
|
49
49
|
<dd>The prompt to generate a response for.</dd>
|
|
50
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
|
+
|
|
51
58
|
<dt class="optional">
|
|
52
59
|
payload.images
|
|
53
60
|
|
|
54
61
|
<span class="property-type">array</span>
|
|
55
62
|
</dt>
|
|
56
|
-
<dd>
|
|
63
|
+
<dd>A list of base64-encoded images (for multimodal models such as <code>llava</code>)</dd>
|
|
57
64
|
|
|
58
65
|
<dt class="optional">
|
|
59
|
-
payload.
|
|
66
|
+
payload.format
|
|
60
67
|
|
|
61
68
|
<span class="property-type">string</span>
|
|
62
69
|
</dt>
|
|
63
|
-
<dd>
|
|
70
|
+
<dd>The format to return a response in. Currently the only accepted value is <code>json</code></dd>
|
|
64
71
|
|
|
65
72
|
<dt class="optional">
|
|
66
|
-
payload.
|
|
73
|
+
payload.options
|
|
67
74
|
|
|
68
|
-
<span class="property-type">
|
|
75
|
+
<span class="property-type">object</span>
|
|
69
76
|
</dt>
|
|
70
|
-
<dd>
|
|
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>
|
|
71
80
|
|
|
72
81
|
<dt class="optional">
|
|
73
|
-
payload.
|
|
82
|
+
payload.system
|
|
74
83
|
|
|
75
|
-
<span class="property-type">
|
|
84
|
+
<span class="property-type">string</span>
|
|
76
85
|
</dt>
|
|
77
|
-
<dd>
|
|
86
|
+
<dd>System message to (overrides what is defined in the <code>Modelfile</code>)</dd>
|
|
78
87
|
|
|
79
88
|
<dt class="optional">
|
|
80
|
-
payload.
|
|
89
|
+
payload.template
|
|
81
90
|
|
|
82
91
|
<span class="property-type">string</span>
|
|
83
92
|
</dt>
|
|
84
|
-
<dd>
|
|
93
|
+
<dd>The prompt template to use (overrides what is defined in the <code>Modelfile</code>)</dd>
|
|
85
94
|
|
|
86
95
|
<dt class="optional">
|
|
87
96
|
payload.stream
|
|
88
97
|
|
|
89
98
|
<span class="property-type">boolean</span>
|
|
90
99
|
</dt>
|
|
91
|
-
<dd>
|
|
100
|
+
<dd>If <code>false</code> the response will be returned as a single response object, rather than a stream of objects.</dd>
|
|
92
101
|
|
|
93
102
|
<dt class="optional">
|
|
94
|
-
payload.
|
|
103
|
+
payload.raw
|
|
95
104
|
|
|
96
|
-
<span class="property-type">
|
|
105
|
+
<span class="property-type">boolean</span>
|
|
97
106
|
</dt>
|
|
98
|
-
<dd>
|
|
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>
|
|
99
111
|
|
|
100
112
|
<dt class="optional">
|
|
101
|
-
payload.
|
|
113
|
+
payload.keep_alive
|
|
102
114
|
|
|
103
|
-
<span class="property-type">
|
|
115
|
+
<span class="property-type">string | number</span>
|
|
104
116
|
</dt>
|
|
105
|
-
<dd>
|
|
106
|
-
Options to configure the runtime.<br />
|
|
107
|
-
|
|
108
|
-
<h4>Options</h4>
|
|
109
|
-
<dl class="message-properties">
|
|
110
|
-
<dt>
|
|
111
|
-
numa
|
|
112
|
-
|
|
113
|
-
<span class="property-type">boolean</span>
|
|
114
|
-
</dt>
|
|
115
|
-
<dd>Use NUMA for the runtime.</dd>
|
|
116
|
-
|
|
117
|
-
<dt>
|
|
118
|
-
num_ctx
|
|
119
|
-
|
|
120
|
-
<span class="property-type">number</span>
|
|
121
|
-
</dt>
|
|
122
|
-
<dd>The number of contexts to use.</dd>
|
|
123
|
-
|
|
124
|
-
<dt>
|
|
125
|
-
num_batch
|
|
126
|
-
|
|
127
|
-
<span class="property-type">number</span>
|
|
128
|
-
</dt>
|
|
129
|
-
<dd>The number of batches to use.</dd>
|
|
130
|
-
|
|
131
|
-
<dt>
|
|
132
|
-
main_gpu
|
|
133
|
-
|
|
134
|
-
<span class="property-type">number</span>
|
|
135
|
-
</dt>
|
|
136
|
-
<dd>The main GPU to use.</dd>
|
|
137
|
-
|
|
138
|
-
<dt>
|
|
139
|
-
low_vram
|
|
140
|
-
|
|
141
|
-
<span class="property-type">boolean</span>
|
|
142
|
-
</dt>
|
|
143
|
-
<dd>Use low VRAM.</dd>
|
|
144
|
-
|
|
145
|
-
<dt>
|
|
146
|
-
f16_kv
|
|
147
|
-
|
|
148
|
-
<span class="property-type">boolean</span>
|
|
149
|
-
</dt>
|
|
150
|
-
<dd>Use f16 key-value.</dd>
|
|
151
|
-
|
|
152
|
-
<dt>
|
|
153
|
-
logits_all
|
|
154
|
-
|
|
155
|
-
<span class="property-type">boolean</span>
|
|
156
|
-
</dt>
|
|
157
|
-
<dd>Return all logits.</dd>
|
|
158
|
-
|
|
159
|
-
<dt>
|
|
160
|
-
vocab_only
|
|
161
|
-
|
|
162
|
-
<span class="property-type">boolean</span>
|
|
163
|
-
</dt>
|
|
164
|
-
<dd>Return only the vocabulary.</dd>
|
|
165
|
-
|
|
166
|
-
<dt>
|
|
167
|
-
use_nmap
|
|
168
|
-
|
|
169
|
-
<span class="property-type">boolean</span>
|
|
170
|
-
</dt>
|
|
171
|
-
<dd>Use NMAP.</dd>
|
|
172
|
-
|
|
173
|
-
<dt>
|
|
174
|
-
use_mlock
|
|
175
|
-
|
|
176
|
-
<span class="property-type">boolean</span>
|
|
177
|
-
</dt>
|
|
178
|
-
<dd>Use mlock.</dd>
|
|
179
|
-
|
|
180
|
-
<dt>
|
|
181
|
-
embedding_only
|
|
182
|
-
|
|
183
|
-
<span class="property-type">boolean</span>
|
|
184
|
-
</dt>
|
|
185
|
-
<dd>Return only the embeddings.</dd>
|
|
186
|
-
|
|
187
|
-
<dt>
|
|
188
|
-
num_thread
|
|
189
|
-
|
|
190
|
-
<span class="property-type">number</span>
|
|
191
|
-
</dt>
|
|
192
|
-
<dd>The number of threads to use.</dd>
|
|
193
|
-
|
|
194
|
-
<dt>
|
|
195
|
-
num_keep
|
|
196
|
-
|
|
197
|
-
<span class="property-type">number</span>
|
|
198
|
-
</dt>
|
|
199
|
-
<dd>The number of models to keep.</dd>
|
|
200
|
-
|
|
201
|
-
<dt>
|
|
202
|
-
seed
|
|
203
|
-
|
|
204
|
-
<span class="property-type">number</span>
|
|
205
|
-
</dt>
|
|
206
|
-
<dd>The seed to use.</dd>
|
|
207
|
-
|
|
208
|
-
<dt>
|
|
209
|
-
num_predict
|
|
210
|
-
|
|
211
|
-
<span class="property-type">number</span>
|
|
212
|
-
</dt>
|
|
213
|
-
<dd>The number of predictions to use.</dd>
|
|
214
|
-
|
|
215
|
-
<dt>
|
|
216
|
-
top_k
|
|
217
|
-
|
|
218
|
-
<span class="property-type">number</span>
|
|
219
|
-
</dt>
|
|
220
|
-
<dd>The top k to use.</dd>
|
|
221
|
-
|
|
222
|
-
<dt>
|
|
223
|
-
top_p
|
|
224
|
-
|
|
225
|
-
<span class="property-type">number</span>
|
|
226
|
-
</dt>
|
|
227
|
-
<dd>The top p to use.</dd>
|
|
228
|
-
|
|
229
|
-
<dt>
|
|
230
|
-
typical_p
|
|
231
|
-
|
|
232
|
-
<span class="property-type">number</span>
|
|
233
|
-
</dt>
|
|
234
|
-
<dd>The typical p to use.</dd>
|
|
235
|
-
|
|
236
|
-
<dt>
|
|
237
|
-
repeat_last_n
|
|
238
|
-
|
|
239
|
-
<span class="property-type">number</span>
|
|
240
|
-
</dt>
|
|
241
|
-
<dd>The repeat last n to use.</dd>
|
|
242
|
-
|
|
243
|
-
<dt>
|
|
244
|
-
temperature
|
|
245
|
-
|
|
246
|
-
<span class="property-type">number</span>
|
|
247
|
-
</dt>
|
|
248
|
-
<dd>The temperature to use.</dd>
|
|
249
|
-
|
|
250
|
-
<dt>
|
|
251
|
-
repeat_pentalty
|
|
252
|
-
|
|
253
|
-
<span class="property-type">number</span>
|
|
254
|
-
</dt>
|
|
255
|
-
<dd>The repeat pentalty to use.</dd>
|
|
256
|
-
|
|
257
|
-
<dt>
|
|
258
|
-
presence_penalty
|
|
259
|
-
|
|
260
|
-
<span class="property-type">number</span>
|
|
261
|
-
</dt>
|
|
262
|
-
<dd>The presence penalty to use.</dd>
|
|
263
|
-
|
|
264
|
-
<dt>
|
|
265
|
-
frequency_penalty
|
|
266
|
-
|
|
267
|
-
<span class="property-type">number</span>
|
|
268
|
-
</dt>
|
|
269
|
-
<dd>The frequency penalty to use.</dd>
|
|
270
|
-
|
|
271
|
-
<dt>
|
|
272
|
-
mirostat
|
|
273
|
-
|
|
274
|
-
<span class="property-type">boolean</span>
|
|
275
|
-
</dt>
|
|
276
|
-
<dd>Use mirostat.</dd>
|
|
277
|
-
|
|
278
|
-
<dt>
|
|
279
|
-
mirostat_tau
|
|
280
|
-
|
|
281
|
-
<span class="property-type">number</span>
|
|
282
|
-
</dt>
|
|
283
|
-
|
|
284
|
-
<dt>
|
|
285
|
-
mirostat_eta
|
|
286
|
-
|
|
287
|
-
<span class="property-type">number</span>
|
|
288
|
-
</dt>
|
|
289
|
-
|
|
290
|
-
<dt>
|
|
291
|
-
penalize_newline
|
|
292
|
-
|
|
293
|
-
<span class="property-type">boolean</span>
|
|
294
|
-
</dt>
|
|
295
|
-
<dd>Penalize newline.</dd>
|
|
296
|
-
|
|
297
|
-
<dt>
|
|
298
|
-
stop
|
|
299
|
-
|
|
300
|
-
<span class="property-type">array</span>
|
|
301
|
-
</dt>
|
|
302
|
-
<dd>The stop to use.</dd>
|
|
303
|
-
</dl>
|
|
304
|
-
</dd>
|
|
117
|
+
<dd>Controls how long the model will stay loaded into memory following the request (default: <code>5m</code>)</dd>
|
|
305
118
|
</dl>
|
|
306
119
|
|
|
307
120
|
<h3>Outputs</h3>
|
package/nodes/ollama-generate.js
CHANGED
|
@@ -6,14 +6,39 @@ module.exports = function( RED ) {
|
|
|
6
6
|
const node = this
|
|
7
7
|
|
|
8
8
|
node.on( 'input', async function( msg ) {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
host,
|
|
11
|
+
model,
|
|
12
|
+
prompt,
|
|
13
|
+
suffix,
|
|
14
|
+
system,
|
|
15
|
+
template,
|
|
16
|
+
raw,
|
|
17
|
+
images,
|
|
18
|
+
format,
|
|
19
|
+
stream,
|
|
20
|
+
keep_alive,
|
|
21
|
+
options
|
|
22
|
+
} = msg.payload
|
|
10
23
|
|
|
11
24
|
const ollama = new Ollama( { host } )
|
|
12
25
|
|
|
13
|
-
const response = await ollama.generate( {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
const response = await ollama.generate( {
|
|
27
|
+
model,
|
|
28
|
+
prompt,
|
|
29
|
+
suffix,
|
|
30
|
+
system,
|
|
31
|
+
template,
|
|
32
|
+
raw,
|
|
33
|
+
images,
|
|
34
|
+
format,
|
|
35
|
+
stream,
|
|
36
|
+
keep_alive,
|
|
37
|
+
options
|
|
38
|
+
} )
|
|
39
|
+
.catch( error => {
|
|
40
|
+
node.error( error )
|
|
41
|
+
} )
|
|
17
42
|
|
|
18
43
|
msg.payload = response
|
|
19
44
|
node.send( msg )
|
package/nodes/ollama-list.html
CHANGED
package/nodes/ollama-list.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType( 'ollama-ps', {
|
|
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-ps';
|
|
13
|
+
},
|
|
14
|
+
} )
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="ollama-ps">
|
|
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-ps">
|
|
25
|
+
<p>List models that are currently loaded into memory.</p>
|
|
26
|
+
|
|
27
|
+
<h3>Inputs</h3>
|
|
28
|
+
|
|
29
|
+
<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
|
+
</dl>
|
|
37
|
+
|
|
38
|
+
<h3>Outputs</h3>
|
|
39
|
+
|
|
40
|
+
<dl class="message-properties">
|
|
41
|
+
<dt>
|
|
42
|
+
payload.models
|
|
43
|
+
|
|
44
|
+
<span class="property-type">array</span>
|
|
45
|
+
</dt>
|
|
46
|
+
<dd>
|
|
47
|
+
The list of models that are available locally.<br />
|
|
48
|
+
|
|
49
|
+
<h4>Model</h4>
|
|
50
|
+
<dl class="message-properties">
|
|
51
|
+
<dt>
|
|
52
|
+
name
|
|
53
|
+
|
|
54
|
+
<span class="property-type">string</span>
|
|
55
|
+
</dt>
|
|
56
|
+
|
|
57
|
+
<dt>
|
|
58
|
+
model
|
|
59
|
+
|
|
60
|
+
<span class="property-type">string</span>
|
|
61
|
+
</dt>
|
|
62
|
+
|
|
63
|
+
<dt>
|
|
64
|
+
size
|
|
65
|
+
|
|
66
|
+
<span class="property-type">number</span>
|
|
67
|
+
</dt>
|
|
68
|
+
|
|
69
|
+
<dt>
|
|
70
|
+
digest
|
|
71
|
+
|
|
72
|
+
<span class="property-type">string</span>
|
|
73
|
+
</dt>
|
|
74
|
+
|
|
75
|
+
<dt>
|
|
76
|
+
expires_at
|
|
77
|
+
|
|
78
|
+
<span class="property-type">Date</span>
|
|
79
|
+
</dt>
|
|
80
|
+
|
|
81
|
+
<dt>
|
|
82
|
+
size_vram
|
|
83
|
+
|
|
84
|
+
<span class="property-type">number</span>
|
|
85
|
+
</dt>
|
|
86
|
+
|
|
87
|
+
<dt>
|
|
88
|
+
details
|
|
89
|
+
|
|
90
|
+
<span class="property-type">object</span>
|
|
91
|
+
</dt>
|
|
92
|
+
<dd>
|
|
93
|
+
The details of the model.<br />
|
|
94
|
+
|
|
95
|
+
<h5>Details</h5>
|
|
96
|
+
<dl class="message-properties">
|
|
97
|
+
<dt>
|
|
98
|
+
parent_model
|
|
99
|
+
|
|
100
|
+
<span class="property-type">string</span>
|
|
101
|
+
</dt>
|
|
102
|
+
|
|
103
|
+
<dt>
|
|
104
|
+
format
|
|
105
|
+
|
|
106
|
+
<span class="property-type">string</span>
|
|
107
|
+
</dt>
|
|
108
|
+
|
|
109
|
+
<dt>
|
|
110
|
+
family
|
|
111
|
+
|
|
112
|
+
<span class="property-type">string</span>
|
|
113
|
+
</dt>
|
|
114
|
+
|
|
115
|
+
<dt>
|
|
116
|
+
families
|
|
117
|
+
|
|
118
|
+
<span class="property-type">array</span>
|
|
119
|
+
</dt>
|
|
120
|
+
|
|
121
|
+
<dt>
|
|
122
|
+
parameter_size
|
|
123
|
+
|
|
124
|
+
<span class="property-type">string</span>
|
|
125
|
+
</dt>
|
|
126
|
+
|
|
127
|
+
<dt>
|
|
128
|
+
quiantization_level
|
|
129
|
+
|
|
130
|
+
<span class="property-type">string</span>
|
|
131
|
+
</dt>
|
|
132
|
+
</dl>
|
|
133
|
+
</dd>
|
|
134
|
+
</dl>
|
|
135
|
+
</dd>
|
|
136
|
+
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = function( RED ) {
|
|
2
|
+
const { Ollama } = require( 'ollama' )
|
|
3
|
+
|
|
4
|
+
function OllamaPsNode( config ) {
|
|
5
|
+
RED.nodes.createNode( this, config )
|
|
6
|
+
const node = this
|
|
7
|
+
|
|
8
|
+
node.on( 'input', async function( msg ) {
|
|
9
|
+
const { host } = msg.payload
|
|
10
|
+
|
|
11
|
+
const ollama = new Ollama( { host } )
|
|
12
|
+
|
|
13
|
+
const response = await ollama.ps()
|
|
14
|
+
.catch( error => {
|
|
15
|
+
node.error( error )
|
|
16
|
+
} )
|
|
17
|
+
|
|
18
|
+
msg.payload = response
|
|
19
|
+
node.send( msg )
|
|
20
|
+
} )
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
RED.nodes.registerType( 'ollama-ps', OllamaPsNode )
|
|
24
|
+
}
|
package/nodes/ollama-pull.html
CHANGED
|
File without changes
|
package/nodes/ollama-pull.js
CHANGED
|
File without changes
|
package/nodes/ollama-push.html
CHANGED
|
File without changes
|
package/nodes/ollama-push.js
CHANGED
|
File without changes
|
package/nodes/ollama-show.html
CHANGED
|
File without changes
|
package/nodes/ollama-show.js
CHANGED
|
@@ -6,14 +6,25 @@ module.exports = function( RED ) {
|
|
|
6
6
|
const node = this
|
|
7
7
|
|
|
8
8
|
node.on( 'input', async function( msg ) {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
host,
|
|
11
|
+
model,
|
|
12
|
+
system,
|
|
13
|
+
template,
|
|
14
|
+
options
|
|
15
|
+
} = msg.payload
|
|
10
16
|
|
|
11
17
|
const ollama = new Ollama( { host } )
|
|
12
18
|
|
|
13
|
-
const response = await ollama.show( {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
const response = await ollama.show( {
|
|
20
|
+
model,
|
|
21
|
+
system,
|
|
22
|
+
template,
|
|
23
|
+
options
|
|
24
|
+
} )
|
|
25
|
+
.catch( error => {
|
|
26
|
+
node.error( error )
|
|
27
|
+
} )
|
|
17
28
|
|
|
18
29
|
msg.payload = response
|
|
19
30
|
node.send( msg )
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-ollama",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
@@ -21,19 +21,21 @@
|
|
|
21
21
|
"ollama-copy": "nodes/ollama-copy.js",
|
|
22
22
|
"ollama-create": "nodes/ollama-create.js",
|
|
23
23
|
"ollama-delete": "nodes/ollama-delete.js",
|
|
24
|
-
"ollama-
|
|
24
|
+
"ollama-embed": "nodes/ollama-embed.js",
|
|
25
25
|
"ollama-generate": "nodes/ollama-generate.js",
|
|
26
26
|
"ollama-list": "nodes/ollama-list.js",
|
|
27
27
|
"ollama-pull": "nodes/ollama-pull.js",
|
|
28
28
|
"ollama-push": "nodes/ollama-push.js",
|
|
29
|
-
"ollama-show": "nodes/ollama-show.js"
|
|
29
|
+
"ollama-show": "nodes/ollama-show.js",
|
|
30
|
+
"ollama-ps": "nodes/ollama-ps.js",
|
|
31
|
+
"ollama-abort": "nodes/ollama-abort.js"
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
34
|
"engines": {
|
|
33
35
|
"node": ">=18.0.0"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"ollama": "^0.5.
|
|
38
|
+
"ollama": "^0.5.9"
|
|
37
39
|
},
|
|
38
40
|
"bugs": {
|
|
39
41
|
"url": "https://github.com/jakubburkiewicz/node-red-contrib-ollama/issues"
|