@inductiv/node-red-openai-api 0.5.0 → 0.6.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/README.md +12 -16
- package/locales/en-US/node.json +2 -1
- package/node.html +25 -2
- package/node.js +15 -4
- package/package.json +1 -1
- package/.eslintrc.json +0 -12
- package/.prettierrc +0 -4
package/README.md
CHANGED
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
_@inductiv/node-red-openai-api_ offers a versatile and configurable Node-RED node, designed specifically for seamless integration with OpenAI's advanced platform services. It empowers you to effortlessly connect and orchestrate various OpenAI functionalities, leveraging the full power of Node-RED's sophisticated application nodes. Whether you're aiming to enhance your workflows with cutting-edge AI capabilities or create innovative applications, this node serves as your gateway to harnessing the latest in AI technology from OpenAI, all within the intuitive and flexible environment of Node-RED.
|
|
11
11
|
|
|
12
|
-
## New in Version 0.
|
|
12
|
+
## New in Version 0.6.0
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
-
|
|
14
|
+
- The node now has a customizable input type field in the editor dialog.
|
|
15
|
+
- You can now configure your API call payload using either a `msg`, `flow`, or `global` property setting. This brings even greater contextual control to your AI requests.
|
|
16
|
+
- **Note:** Existing implementations default to `msg.payload` and _should_ continue to work as implemented using previous versions of this node.
|
|
17
|
+
|
|
18
|
+
Please report any issues [here on Github](https://github.com/allanbunch/node-red-openai-api/issues).
|
|
17
19
|
|
|
18
20
|
## Key Features
|
|
19
21
|
|
|
@@ -92,21 +94,15 @@ I very much appreciate community input and invite everyone to shape the future o
|
|
|
92
94
|
|
|
93
95
|
### Engage in Various Discussions
|
|
94
96
|
|
|
95
|
-
- **Announcements**: Stay updated with the latest project news.
|
|
96
|
-
- **General**: Share thoughts or seek advice on broader topics.
|
|
97
|
-
- **Ideas**: Propose new features or improvements.
|
|
98
|
-
- **Polls**: Participate in polls to influence project decisions.
|
|
99
|
-
- **Q&A**: Get answers to your questions and share your expertise.
|
|
100
|
-
- **Show and Tell**: Showcase your creative implementations and inspire others.
|
|
97
|
+
- **[Announcements](https://github.com/allanbunch/node-red-openai-api/discussions/categories/announcements)**: Stay updated with the latest project news.
|
|
98
|
+
- **[General](https://github.com/allanbunch/node-red-openai-api/discussions/categories/general)**: Share thoughts or seek advice on broader topics.
|
|
99
|
+
- **[Ideas](https://github.com/allanbunch/node-red-openai-api/discussions/categories/ideas)**: Propose new features or improvements.
|
|
100
|
+
- **[Polls](https://github.com/allanbunch/node-red-openai-api/discussions/categories/polls)**: Participate in polls to influence project decisions.
|
|
101
|
+
- **[Q&A](https://github.com/allanbunch/node-red-openai-api/discussions/categories/q-a)**: Get answers to your questions and share your expertise.
|
|
102
|
+
- **[Show and Tell](https://github.com/allanbunch/node-red-openai-api/discussions/categories/show-and-tell)**: Showcase your creative implementations and inspire others.
|
|
101
103
|
|
|
102
104
|
Join the conversation [here](https://github.com/allanbunch/node-red-openai-api/discussions) and let's build a vibrant and collaborative community together!
|
|
103
105
|
|
|
104
106
|
## License
|
|
105
107
|
|
|
106
108
|
[MIT](./LICENSE)
|
|
107
|
-
|
|
108
|
-
## Acknowledgements
|
|
109
|
-
|
|
110
|
-
- [node-red-nodegen](https://github.com/node-red/node-red-nodegen)
|
|
111
|
-
- For boilerplate code generation, though the auto-generated code has been largely refactored.
|
|
112
|
-
- **Note:** This package uses `axios` in place of node-red-nodegen's `request` default.
|
package/locales/en-US/node.json
CHANGED
package/node.html
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
color: "#B8B1FB",
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: "" },
|
|
7
|
+
property: { value: "payload", required: true },
|
|
8
|
+
propertyType: { value: "msg" },
|
|
7
9
|
service: { value: "", type: "Service Host", required: true },
|
|
8
10
|
method: { value: "", required: true },
|
|
9
11
|
},
|
|
@@ -22,8 +24,20 @@
|
|
|
22
24
|
var methods = $("#node-input-method").children();
|
|
23
25
|
var firstMethod = methods.first();
|
|
24
26
|
$("#node-input-method").val(firstMethod.val());
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// set the default property type value to "payload"
|
|
30
|
+
if (this.property === undefined) {
|
|
31
|
+
$("#node-input-property").val("payload");
|
|
25
32
|
}
|
|
26
|
-
|
|
33
|
+
|
|
34
|
+
$("#node-input-property").typedInput({
|
|
35
|
+
default: "msg",
|
|
36
|
+
value: "payload",
|
|
37
|
+
types:["msg", "flow", "global"],
|
|
38
|
+
typeField: "#node-input-propertyType"
|
|
39
|
+
})
|
|
40
|
+
}
|
|
27
41
|
});
|
|
28
42
|
</script>
|
|
29
43
|
|
|
@@ -49,6 +63,15 @@
|
|
|
49
63
|
<input type="text" id="node-input-service" />
|
|
50
64
|
</div>
|
|
51
65
|
|
|
66
|
+
<div class="form-row">
|
|
67
|
+
<label for="node-input-property"
|
|
68
|
+
><i class="fa fa-ellipsis-h"></i>
|
|
69
|
+
<span data-i18n="OpenaiApi.label.property"></span
|
|
70
|
+
></label>
|
|
71
|
+
<input type="text" id="node-input-property">
|
|
72
|
+
<input type="hidden" id="node-input-propertyType">
|
|
73
|
+
</div>
|
|
74
|
+
|
|
52
75
|
<div class="form-row">
|
|
53
76
|
<label for="node-input-method"
|
|
54
77
|
><i class="fa fa-tasks"></i>
|
|
@@ -2681,7 +2704,7 @@
|
|
|
2681
2704
|
);
|
|
2682
2705
|
if (!selected.val()) {
|
|
2683
2706
|
$("#node-config-input-secureApiKeyIsQuery").val(false);
|
|
2684
|
-
}
|
|
2707
|
+
};
|
|
2685
2708
|
},
|
|
2686
2709
|
});
|
|
2687
2710
|
</script>
|
package/node.js
CHANGED
|
@@ -5,21 +5,32 @@ module.exports = function (RED) {
|
|
|
5
5
|
class OpenaiApiNode {
|
|
6
6
|
constructor(config) {
|
|
7
7
|
RED.nodes.createNode(this, config);
|
|
8
|
-
this.service = RED.nodes.getNode(config.service);
|
|
9
|
-
this.method = config.method;
|
|
10
8
|
|
|
11
9
|
let node = this;
|
|
10
|
+
node.service = RED.nodes.getNode(config.service);
|
|
11
|
+
node.config = config;
|
|
12
12
|
|
|
13
13
|
node.on("input", function (msg) {
|
|
14
14
|
let client = new lib.OpenaiApi();
|
|
15
|
+
let payload;
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
+
const propertyType = node.config.propertyType || "msg";
|
|
18
|
+
const propertyPath = node.config.property || "payload";
|
|
19
|
+
|
|
20
|
+
if (propertyType === "msg") {
|
|
21
|
+
payload = RED.util.getMessageProperty(msg, propertyPath);
|
|
22
|
+
} else {
|
|
23
|
+
// For flow and global contexts
|
|
24
|
+
payload = node.context()[propertyType].get(propertyPath);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const serviceName = node.config.method; // Set the service name to call.
|
|
17
28
|
let serviceParametersObject = {
|
|
18
29
|
organization: node.service.organizationId,
|
|
19
30
|
apiBase: node.service.apiBase,
|
|
20
31
|
apiKey: node.service.credentials.secureApiKeyValue || "",
|
|
21
32
|
_node: node,
|
|
22
|
-
payload:
|
|
33
|
+
payload: payload,
|
|
23
34
|
};
|
|
24
35
|
|
|
25
36
|
// Dynamically call the function based on the service name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inductiv/node-red-openai-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Go beyond ChatGPT and DALL·E 3: this Node-RED node seamlessly integrates a range of OpenAI services, including Assistants, Threads, Vision, and Audio, enabling feature-rich enhancement of your AI workflows with any OpenAI REST API-compatible solution.",
|
|
5
5
|
"main": "node.js",
|
|
6
6
|
"engines": {
|
package/.eslintrc.json
DELETED
package/.prettierrc
DELETED