@inductiv/node-red-openai-api 1.85.1 → 1.87.3

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 CHANGED
@@ -40,10 +40,34 @@ After installation, find your node in the **AI** palette category labeled "OpenA
40
40
  - **Configurable and Flexible**: Adapt to a wide range of project requirements, making it easy to integrate AI into your IoT solutions.
41
41
  - **Powerful Combinations**: Utilize Node-RED's diverse nodes to build complex, AI-driven IoT workflows with ease.
42
42
 
43
- ## Release Notes (v1.85.1)
44
-
45
- - **Ehancement**: Upgraded the OpenAI API Library dependency from [v4.83.0](https://github.com/openai/openai-node/releases/tag/v4.83.0) to [v4.85.1](https://github.com/openai/openai-node/releases/tag/v4.85.1).
46
- - Project versioning now aligns with the OpenAI API Library's minor and patch version numbers for easier feature tracking and compatibility (e.g., x.85.1).
43
+ ## Release Notes (v1.87.3)
44
+
45
+ - **Ehancement:** Upgraded the OpenAI API Library dependency from [v4.85.4](https://github.com/openai/openai-node/releases/tag/v4.85.4) to [v4.87.3](https://github.com/openai/openai-node/releases/tag/v4.87.3).
46
+ - **Features:** Implemented [Responses](https://platform.openai.com/docs/api-reference/responses) API capabilities.
47
+ - OpenAI's most advanced interface for generating model responses.
48
+ - Create stateful interactions with the model, using the output of previous responses as input and more.
49
+ - 🔥 Native agentic web search capabilities:
50
+
51
+ ```javascript
52
+ msg.payload = {
53
+ "model": "gpt-4o-mini",
54
+ "tools": [{ type: "web_search_preview" }],
55
+ "input": "What was a positive news story from today?"
56
+ }
57
+ ```
58
+
59
+ - 🔥 Native agentic computer use capabilities.
60
+ - 🔥 Reasoning model control properties:
61
+
62
+ ```javascript
63
+ msg.payload = {
64
+ "model": "o3-mini",
65
+ "input": "How much wood would a woodchuck chuck?",
66
+ "reasoning": {
67
+ "effort": "high"
68
+ }
69
+ }
70
+ ```
47
71
 
48
72
  ## What's New in Version 1.x
49
73
 
package/lib.js CHANGED
@@ -250,6 +250,61 @@ let OpenaiApi = (function () {
250
250
  }
251
251
  }
252
252
 
253
+ async getChatCompletion(parameters) {
254
+ const openai = new OpenAI(this.clientParams);
255
+ const { completion_id, ...options } = parameters.payload;
256
+
257
+ const response = await openai.chat.completions.retrieve(
258
+ completion_id,
259
+ options
260
+ );
261
+
262
+ return response;
263
+ }
264
+
265
+ async getChatMessages(parameters) {
266
+ const openai = new OpenAI(this.clientParams);
267
+ const { completion_id, ...options } = parameters.payload;
268
+
269
+ const response = await openai.chat.completions.messages.list(
270
+ completion_id,
271
+ options
272
+ );
273
+
274
+ return response.data;
275
+ }
276
+
277
+ async listChatCompletions(parameters) {
278
+ const openai = new OpenAI(this.clientParams);
279
+ const response = await openai.chat.completions.list(parameters.payload);
280
+
281
+ return response.data;
282
+ }
283
+
284
+ async updateChatCompletion(parameters) {
285
+ const openai = new OpenAI(this.clientParams);
286
+ const { completion_id, ...body } = parameters.payload;
287
+
288
+ const response = await openai.chat.completions.update(
289
+ completion_id,
290
+ body
291
+ );
292
+
293
+ return response;
294
+ }
295
+
296
+ async deleteChatCompletion(parameters) {
297
+ const openai = new OpenAI(this.clientParams);
298
+ const { completion_id, ...options } = parameters.payload;
299
+
300
+ const response = await openai.chat.completions.del(
301
+ completion_id,
302
+ options
303
+ );
304
+
305
+ return response;
306
+ }
307
+
253
308
  async createImage(parameters) {
254
309
  const openai = new OpenAI(this.clientParams);
255
310
  const response = await openai.images.generate(parameters.payload);
@@ -440,6 +495,59 @@ let OpenaiApi = (function () {
440
495
  return response;
441
496
  }
442
497
 
498
+ // >>> Begin Responses functions
499
+ async createModelResponse(parameters) {
500
+ const { _node, ...params } = parameters;
501
+ const openai = new OpenAI(this.clientParams);
502
+ const response = await openai.responses.create(parameters.payload);
503
+
504
+ if (params.payload.stream) {
505
+ _node.status({
506
+ fill: "green",
507
+ shape: "dot",
508
+ text: "OpenaiApi.status.streaming",
509
+ });
510
+ for await (const chunk of response) {
511
+ if (typeof chunk === "object") {
512
+ const newMsg = { ...parameters.msg, payload: chunk };
513
+ _node.send(newMsg);
514
+ }
515
+ }
516
+ _node.status({});
517
+ } else {
518
+ return response;
519
+ }
520
+ }
521
+
522
+ async getModelResponse(parameters) {
523
+ const openai = new OpenAI(this.clientParams);
524
+ const { response_id, ...params } = parameters.payload;
525
+ const response = await openai.responses.retrieve(
526
+ response_id,
527
+ params
528
+ );
529
+
530
+ return response;
531
+ }
532
+
533
+ async deleteModelResponse(parameters) {
534
+ const openai = new OpenAI(this.clientParams);
535
+ const { response_id, ...params } = parameters.payload;
536
+ const response = await openai.responses.del(response_id, params);
537
+
538
+ return response;
539
+ }
540
+
541
+ async listInputItems(parameters) {
542
+ const openai = new OpenAI(this.clientParams);
543
+ const { response_id, ...params } = parameters.payload;
544
+ const list = await openai.responses.inputItems.list(response_id, params);
545
+
546
+ return [...list.data];
547
+ }
548
+
549
+ // <<< End Responses functions
550
+
443
551
  async createModeration(parameters) {
444
552
  const openai = new OpenAI(this.clientParams);
445
553
  const response = await openai.moderations.create(parameters.payload);
@@ -35,6 +35,11 @@
35
35
  "cancelBatch": "cancel batch",
36
36
  "listBatch": "list batch",
37
37
  "createChatCompletion": "create chat completion",
38
+ "getChatCompletion": "get chat completion",
39
+ "getChatMessages": "get chat messages",
40
+ "listChatCompletions": "list chat completions",
41
+ "updateChatCompletion": "update chat completion",
42
+ "deleteChatCompletion": "delete chat completion",
38
43
  "body": "body",
39
44
  "request_body": "Request Body",
40
45
  "data": "data",
@@ -35,6 +35,11 @@
35
35
  "cancelBatch": "cancel batch",
36
36
  "listBatch": "list batch",
37
37
  "createChatCompletion": "create chat completion",
38
+ "getChatCompletion": "get chat completion",
39
+ "getChatMessages": "get chat messages",
40
+ "listChatCompletions": "list chat completions",
41
+ "updateChatCompletion": "update chat completion",
42
+ "deleteChatCompletion": "delete chat completion",
38
43
  "body": "body",
39
44
  "request_body": "Request Body",
40
45
  "data": "data",
@@ -94,6 +99,10 @@
94
99
  "retrieveModel": "retrieve model",
95
100
  "deleteModel": "delete fine-tune model",
96
101
  "createModeration": "create moderation",
102
+ "createModelResponse": "create model response",
103
+ "getModelResponse": "retrieve model response",
104
+ "deleteModelResponse": "delete model response",
105
+ "listInputItems": "list input items",
97
106
  "listAssistants": "list assistants",
98
107
  "order": "order",
99
108
  "before": "before",
@@ -35,6 +35,11 @@
35
35
  "cancelBatch": "cancel batch",
36
36
  "listBatch": "list batch",
37
37
  "createChatCompletion": "create chat completion",
38
+ "getChatCompletion": "get chat completion",
39
+ "getChatMessages": "get chat messages",
40
+ "listChatCompletions": "list chat completions",
41
+ "updateChatCompletion": "update chat completion",
42
+ "deleteChatCompletion": "delete chat completion",
38
43
  "body": "body",
39
44
  "request_body": "Request Body",
40
45
  "data": "data",
@@ -35,6 +35,11 @@
35
35
  "cancelBatch": "cancel batch",
36
36
  "listBatch": "list batch",
37
37
  "createChatCompletion": "create chat completion",
38
+ "getChatCompletion": "get chat completion",
39
+ "getChatMessages": "get chat messages",
40
+ "listChatCompletions": "list chat completions",
41
+ "updateChatCompletion": "update chat completion",
42
+ "deleteChatCompletion": "delete chat completion",
38
43
  "body": "body",
39
44
  "request_body": "Request Body",
40
45
  "data": "data",
@@ -112,9 +117,9 @@
112
117
  "getMessage": "retrieve message",
113
118
  "message_id": "message id",
114
119
  "modifyMessage": "modify message",
115
- "createSession": "create session",
116
120
  "createUpload": "create upload",
117
121
  "addUploadPart": "add upload part",
122
+ "completeUpload": "complete upload",
118
123
  "cancelUpload": "cancel upload",
119
124
  "createThreadAndRun": "create thread and run",
120
125
  "listRuns": "list runs",