@inductiv/node-red-openai-api 1.2.0 → 1.4.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.
Files changed (5) hide show
  1. package/README.md +35 -33
  2. package/lib.js +4 -12
  3. package/node.html +12 -0
  4. package/node.js +3 -3
  5. package/package.json +8 -12
package/README.md CHANGED
@@ -1,14 +1,38 @@
1
- <h1 align="center">
2
- Node-RED OpenAI API: Unleashing AIoT Innovation
3
- <br>
1
+ # @inductiv/node-red-openai-api
2
+
3
+ ![NPM Version](https://img.shields.io/npm/v/%40inductiv%2Fnode-red-openai-api) ![GitHub Release Date](https://img.shields.io/github/release-date/allanbunch/node-red-openai-api) ![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/allanbunch/node-red-openai-api) ![GitHub Repo stars](https://img.shields.io/github/stars/allanbunch/node-red-openai-api)
4
+
5
+ This library provides convenient access to the OpenAI Node API Library from Node-RED.
6
+
4
7
  <a href="https://github.com/allanbunch/node-red-openai-api">
5
8
  <img width="265" alt="node-red-openai-api-node" src="https://github.com/allanbunch/node-red-openai-api/assets/4503640/ee954c8e-fbf4-4812-a38a-f047cecd1982">
6
9
  </a>
7
10
  <br>
11
+
12
+ Node-RED OpenAI API is a versatile and configurable Node-RED node designed for seamless integration with any OpenAI API compatible platform. This node empowers innovators and developers to effortlessly connect and orchestrate complex AI and IoT workflows, leveraging Node-RED's sophisticated ecosystem. Ideal for enhancing IoT operations with advanced AI capabilities, this node serves as your gateway to applying the latest AI technology in an IoT context, facilitating innovative applications across diverse environments.
13
+
14
+ ## Installation
15
+
16
+ ### Via Node-RED Palette Manager
17
+
18
+ ```text
8
19
  @inductiv/node-red-openai-api
9
- </h1>
20
+ ```
10
21
 
11
- Welcome to _@inductiv/node-red-openai-api_, a versatile and configurable Node-RED node designed for seamless integration with any OpenAI API compatible platform. This node empowers innovators and developers to effortlessly connect and orchestrate complex AI and IoT workflows, leveraging Node-RED's sophisticated ecosystem. Ideal for enhancing IoT operations with advanced AI capabilities, this node serves as your gateway to applying the latest AI technology in an IoT context, facilitating innovative applications across diverse environments.
22
+ ### Via NPM
23
+
24
+ ```bash
25
+ cd $HOME/.node-red # or the location of your Node-RED configuration directory.
26
+ npm i @inductiv/node-red-openai-api
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ After installation, find your node in the **AI** palette category labeled "OpenAI API". Here's how you can start integrating AI into your IoT projects:
32
+
33
+ 1. Configure the node with your AI platform's API key (if required).
34
+ 2. Send [OpenAI documented](https://platform.openai.com/docs/api-reference/) API service configuration paramaters to the node using the default `msg.payload` property, or confiure your desired incoming object property reference on the node itself.
35
+ 3. Explore the [examples](./examples/) directory for sample implementations.
12
36
 
13
37
  ## Core Features
14
38
 
@@ -16,11 +40,12 @@ Welcome to _@inductiv/node-red-openai-api_, a versatile and configurable Node-RE
16
40
  - **Configurable and Flexible**: Adapt to a wide range of project requirements, making it easy to integrate AI into your IoT solutions.
17
41
  - **Powerful Combinations**: Utilize Node-RED's diverse nodes to build complex, AI-driven IoT workflows with ease.
18
42
 
19
- ## Release Notes (v1.2.0)
43
+ ## Release Notes (v1.4.0)
20
44
 
21
- - Added the [```fineTuning.jobs.checkpoints.list```](https://platform.openai.com/docs/api-reference/fine-tuning/list-checkpoints) endpoint to the **Fine-tuning** API.
22
- - Updated the node's documentation panel.
23
- - Code stability & formatting updates.
45
+ - Upgraded to OpenAI Node API Library package dependency v4.47.1
46
+ - Supporting OpenAI's new [gpt-4o](https://platform.openai.com/docs/models/gpt-4o) model capabilities
47
+ - Updated the node's documentation panel
48
+ - Code stability & formatting updates
24
49
 
25
50
  ## What's New in Version 1.x
26
51
 
@@ -34,36 +59,13 @@ Version 1.0 of the **node-red-openai-api** node brings significant enhancements
34
59
 
35
60
  ### Important Notice Regarding Compatibility
36
61
 
37
- - **Backward Incompatible Changes**: Please be aware that this version includes breaking changes that may affect existing implementations due to the updated OpenAI NodeJS package:
62
+ - **Backward Incompatible Changes**: Please be aware that v1.0 includes breaking changes that may affect existing implementations (v0.x.x instllations) due to the updated OpenAI NodeJS package:
38
63
  - The API call structure and parameters have been refined to align with the latest OpenAI specifications.
39
64
  - Some functions and settings from previous versions may no longer be compatible with this update.
40
65
  - List responses now exist at the top level of the `msg.payload` object; previously `msg.payload.data`.
41
66
 
42
67
  I recommend reviewing current setups and testing them with this new version in a development environment before updating to ensure a smooth transition. This will help you take full advantage of the enhanced features while managing any necessary adjustments in your existing applications.
43
68
 
44
- ## Installation
45
-
46
- ### Via Node-RED Palette Manager
47
-
48
- ```text
49
- @inductiv/node-red-openai-api
50
- ```
51
-
52
- ### Via NPM
53
-
54
- ```bash
55
- cd $HOME/.node-red
56
- npm i @inductiv/node-red-openai-api
57
- ```
58
-
59
- ## Usage
60
-
61
- After installation, find your node in the **AI** palette category labeled "OpenAI API". Here's how you can start integrating AI into your IoT projects:
62
-
63
- 1. Configure the node with your AI platform's API key (if required).
64
- 2. Send [OpenAI documented](https://platform.openai.com/docs/api-reference/) API service configuration paramaters to the node using the default `msg.payload` property, or confiure your desired incoming object property reference on the node itself.
65
- 3. Explore the [examples](./examples/) directory for sample implementations.
66
-
67
69
  ## Contribute
68
70
 
69
71
  I value community contributions that help enhance this Node-RED node and expand its capabilities in AIoT applications. Whether you're fixing bugs, adding new features, or improving documentation, your help is welcome!
package/lib.js CHANGED
@@ -240,9 +240,7 @@ let OpenaiApi = (function () {
240
240
  });
241
241
  for await (const chunk of response) {
242
242
  if (typeof chunk === "object") {
243
- let { _msgid, ...newMsg } = parameters.msg;
244
- newMsg.payload = chunk;
245
-
243
+ const newMsg = { ...parameters.msg, payload: chunk };
246
244
  _node.send(newMsg);
247
245
  }
248
246
  }
@@ -579,9 +577,7 @@ let OpenaiApi = (function () {
579
577
  });
580
578
  for await (const chunk of response) {
581
579
  if (typeof chunk === "object") {
582
- let { _msgid, ...newMsg } = parameters.msg;
583
- newMsg.payload = chunk.data;
584
-
580
+ const newMsg = { ...parameters.msg, payload: chunk.data };
585
581
  _node.send(newMsg);
586
582
  }
587
583
  }
@@ -613,9 +609,7 @@ let OpenaiApi = (function () {
613
609
  });
614
610
  for await (const chunk of response) {
615
611
  if (typeof chunk === "object") {
616
- let { _msgid, ...newMsg } = parameters.msg;
617
- newMsg.payload = chunk.data;
618
-
612
+ const newMsg = { ...parameters.msg, payload: chunk.data };
619
613
  _node.send(newMsg);
620
614
  }
621
615
  }
@@ -667,9 +661,7 @@ let OpenaiApi = (function () {
667
661
  });
668
662
  for await (const chunk of response) {
669
663
  if (typeof chunk === "object") {
670
- let { _msgid, ...newMsg } = parameters.msg;
671
- newMsg.payload = chunk.data;
672
-
664
+ const newMsg = { ...parameters.msg, payload: chunk.data };
673
665
  _node.send(newMsg);
674
666
  }
675
667
  }
package/node.html CHANGED
@@ -1387,6 +1387,18 @@
1387
1387
  <span class="property-type">boolean</span>
1388
1388
  </dt>
1389
1389
  <dd>If set, partial message deltas will be sent, like in ChatGPT.</dd>
1390
+
1391
+ <dt class="optional">
1392
+ stream_options
1393
+ <a
1394
+ href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-stream_options"
1395
+ target="_blank"
1396
+ ><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
1397
+ ></a>
1398
+ <span class="property-type">object</span>
1399
+ </dt>
1400
+ <dd>Options for streaming response. Only set this when you set ```stream: true```.</dd>
1401
+
1390
1402
  <dt class="optional">
1391
1403
  temperature
1392
1404
  <a
package/node.js CHANGED
@@ -35,9 +35,9 @@ module.exports = function (RED) {
35
35
  const serviceName = node.config.method; // Set the service name to call.
36
36
 
37
37
  let serviceParametersObject = {
38
- "_node": node,
39
- "payload": payload,
40
- "msg": msg
38
+ _node: node,
39
+ payload: payload,
40
+ msg: msg,
41
41
  };
42
42
 
43
43
  // Dynamically call the function based on the service name
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inductiv/node-red-openai-api",
3
- "version": "1.2.0",
4
- "description": "Enhance your Node-RED flows with advanced AI capabilities.",
3
+ "version": "1.4.0",
4
+ "description": "Enhance your Node-RED projects with advanced AI capabilities.",
5
5
  "main": "node.js",
6
6
  "engines": {
7
7
  "node": ">=12.0.0"
@@ -16,30 +16,26 @@
16
16
  "node-red",
17
17
  "aiot",
18
18
  "openai",
19
+ "gpt-4o",
19
20
  "ai",
20
21
  "openai api",
21
- "assistants v2",
22
- "batch requests",
23
- "vector store",
24
22
  "iot",
25
23
  "node-red-contrib",
26
24
  "automation",
27
25
  "smart devices",
28
- "node-red-node",
26
+ "node-red node",
29
27
  "artificial intelligence",
30
28
  "api integration",
31
- "llm",
32
- "slm",
33
29
  "ai agent",
34
30
  "low-code"
35
31
  ],
36
32
  "dependencies": {
37
- "openai": "^4.40.2"
33
+ "openai": "~4.47.1"
38
34
  },
39
35
  "devDependencies": {
40
- "eslint": "^8.54.0",
36
+ "eslint": "^9.2.0",
41
37
  "eslint-plugin-jest": "^28.5.0",
42
- "prettier": "^3.1.0"
38
+ "prettier": "^3.2.5"
43
39
  },
44
40
  "author": "Allan Bunch",
45
41
  "license": "MIT",
@@ -47,4 +43,4 @@
47
43
  "type": "git",
48
44
  "url": "git+https://github.com/allanbunch/node-red-openai-api.git"
49
45
  }
50
- }
46
+ }