@inductiv/node-red-openai-api 1.87.3 → 1.103.0-patch.1

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 (73) hide show
  1. package/README.md +20 -40
  2. package/examples/responses/mcp.json +87 -0
  3. package/gulpfile.js +15 -0
  4. package/lib.js +16420 -538
  5. package/locales/en-US/node.json +10 -0
  6. package/node.html +3050 -3842
  7. package/node.js +3 -2
  8. package/package.json +13 -2
  9. package/src/assistants/help.html +353 -0
  10. package/src/assistants/methods.js +47 -0
  11. package/src/assistants/template.html +38 -0
  12. package/src/audio/help.html +193 -0
  13. package/src/audio/methods.js +38 -0
  14. package/src/audio/template.html +14 -0
  15. package/src/batch/help.html +97 -0
  16. package/src/batch/methods.js +39 -0
  17. package/src/batch/template.html +19 -0
  18. package/src/chat/help.html +436 -0
  19. package/src/chat/methods.js +82 -0
  20. package/src/chat/template.html +30 -0
  21. package/src/container-files/help.html +144 -0
  22. package/src/container-files/methods.js +60 -0
  23. package/src/container-files/template.html +7 -0
  24. package/src/containers/help.html +96 -0
  25. package/src/containers/methods.js +34 -0
  26. package/src/containers/template.html +6 -0
  27. package/src/embeddings/help.html +57 -0
  28. package/src/embeddings/methods.js +12 -0
  29. package/src/embeddings/template.html +6 -0
  30. package/src/files/help.html +102 -0
  31. package/src/files/methods.js +52 -0
  32. package/src/files/template.html +22 -0
  33. package/src/fine-tuning/help.html +187 -0
  34. package/src/fine-tuning/methods.js +68 -0
  35. package/src/fine-tuning/template.html +26 -0
  36. package/src/images/help.html +208 -0
  37. package/src/images/methods.js +38 -0
  38. package/src/images/template.html +14 -0
  39. package/src/lib.js +60 -0
  40. package/src/messages/help.html +194 -0
  41. package/src/messages/methods.js +61 -0
  42. package/src/messages/template.html +7 -0
  43. package/src/models/help.html +47 -0
  44. package/src/models/methods.js +30 -0
  45. package/src/models/template.html +14 -0
  46. package/src/moderations/help.html +31 -0
  47. package/src/moderations/methods.js +11 -0
  48. package/src/moderations/template.html +6 -0
  49. package/src/node.html +250 -0
  50. package/src/responses/help.html +248 -0
  51. package/src/responses/methods.js +55 -0
  52. package/src/responses/template.html +22 -0
  53. package/src/runs/help.html +563 -0
  54. package/src/runs/methods.js +157 -0
  55. package/src/runs/template.html +35 -0
  56. package/src/threads/help.html +88 -0
  57. package/src/threads/methods.js +39 -0
  58. package/src/threads/template.html +18 -0
  59. package/src/uploads/help.html +116 -0
  60. package/src/uploads/methods.js +121 -0
  61. package/src/uploads/template.html +21 -0
  62. package/src/vector-store-file-batches/help.html +156 -0
  63. package/src/vector-store-file-batches/methods.js +84 -0
  64. package/src/vector-store-file-batches/template.html +22 -0
  65. package/src/vector-store-files/help.html +133 -0
  66. package/src/vector-store-files/methods.js +53 -0
  67. package/src/vector-store-files/template.html +18 -0
  68. package/src/vector-stores/help.html +162 -0
  69. package/src/vector-stores/methods.js +48 -0
  70. package/src/vector-stores/template.html +7 -0
  71. package/locales/de-DE/node.json +0 -144
  72. package/locales/ja/node.json +0 -144
  73. package/locales/zh-CN/node.json +0 -144
@@ -0,0 +1,436 @@
1
+ <section>
2
+ <details>
3
+ <summary style="font-weight: bold;">💬 Chat</summary>
4
+ <a href="https://platform.openai.com/docs/api-reference/chat" target="_blank">Official Documentation
5
+ <i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
6
+ <h4 style="font-weight: bolder;"> ⋙ Create Chat Completion</h4>
7
+ <p>
8
+ Creates a model response for the given chat conversation.
9
+ <a href="https://platform.openai.com/docs/api-reference/chat/create" target="_blank">Full documentation.</a>
10
+ </p>
11
+ <dl class="message-properties">
12
+ <h4>msg.payload Properties</h4>
13
+
14
+ <dt>
15
+ messages
16
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages"
17
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
18
+ <span class="property-type">array</span>
19
+ </dt>
20
+ <dd>A list of messages comprising the conversation so far.</dd>
21
+ <dt>
22
+ model
23
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-model"
24
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
25
+ <span class="property-type">string</span>
26
+ </dt>
27
+ <dd>ID of the model to use.</dd>
28
+
29
+ <dt class="optional">
30
+ store
31
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-store"
32
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
33
+ <span class="property-type">boolean | null</span>
34
+ </dt>
35
+ <dd>Whether to store the output of this chat completion request.</dd>
36
+
37
+ <dt class="optional">
38
+ reasoning_effort
39
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-reasoning_effort"
40
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
41
+ <span class="property-type">string</span>
42
+ </dt>
43
+ <dd>Constrains effort on reasoning for reasoning models.</dd>
44
+
45
+ <dt class="optional">
46
+ metadata
47
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-metadata"
48
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
49
+ <span class="property-type">object or null</span>
50
+ </dt>
51
+ <dd>Developer-defined tags and values used for filtering completions in the dashboard.</dd>
52
+
53
+ <dt class="optional">
54
+ frequency_penalty
55
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-frequency_penalty"
56
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
57
+ <span class="property-type">number</span>
58
+ </dt>
59
+ <dd>Number between -2.0 and 2.0.</dd>
60
+ <dt class="optional">
61
+ logit_bias
62
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-logit_bias"
63
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
64
+ <span class="property-type">object</span>
65
+ </dt>
66
+ <dd>
67
+ Modify the likelihood of specified tokens appearing in the completion.
68
+ </dd>
69
+ <dt class="optional">
70
+ logprobs
71
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-logprobs"
72
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
73
+ <span class="property-type">boolean</span>
74
+ </dt>
75
+ <dd>Whether to return log probabilities of the output tokens or not.</dd>
76
+ <dt class="optional">
77
+ top_logprobs
78
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-top_logprobs"
79
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
80
+ <span class="property-type">integer</span>
81
+ </dt>
82
+ <dd>
83
+ An integer between 0 and 5 specifying the number of most likely tokens
84
+ to return at each token position, each with an associated log
85
+ probability.
86
+ </dd>
87
+ <dt class="optional">
88
+ max_tokens [Deprecated]
89
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_tokens"
90
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
91
+ <span class="property-type">integer</span>
92
+ </dt>
93
+ <dd>
94
+ The maximum number of tokens that can be generated in the chat
95
+ completion. This value is now deprecated in favor of max_completion_tokens,
96
+ and is not compatible with o1 series models.
97
+ </dd>
98
+
99
+ <dt class="optional">
100
+ max_completion_tokens
101
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_completion_tokens"
102
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
103
+ <span class="property-type">integer</span>
104
+ </dt>
105
+ <dd>
106
+ An upper bound for the number of tokens that can be generated for a completion,
107
+ including visible output tokens and reasoning tokens.
108
+ </dd>
109
+
110
+ <dt class="optional">
111
+ n
112
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-n" target="_blank"><i
113
+ class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
114
+ <span class="property-type">integer</span>
115
+ </dt>
116
+ <dd>
117
+ How many chat completion choices to generate for each input message.
118
+ </dd>
119
+
120
+ <dt class="optional">
121
+ modalities
122
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-modalities"
123
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
124
+ <span class="property-type">array or null</span>
125
+ </dt>
126
+ <dd>
127
+ Output types that you would like the model to generate for this request.
128
+ </dd>
129
+
130
+ <dt class="optional">
131
+ prediction
132
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-prediction"
133
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
134
+ <span class="property-type">object</span>
135
+ </dt>
136
+ <dd>
137
+ Configuration for a Predicted Output.
138
+ </dd>
139
+
140
+ <dt class="optional">
141
+ audio
142
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-audio"
143
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
144
+ <span class="property-type">object or null</span>
145
+ </dt>
146
+ <dd>
147
+ Parameters for audio output.
148
+ </dd>
149
+
150
+ <dt class="optional">
151
+ presence_penalty
152
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-presence_penalty"
153
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
154
+ <span class="property-type">number</span>
155
+ </dt>
156
+ <dd>Number between -2.0 and 2.0.</dd>
157
+
158
+ <dt class="optional">
159
+ response_format
160
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format"
161
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
162
+ <span class="property-type">object</span>
163
+ </dt>
164
+ <dd>An object specifying the format that the model must output.</dd>
165
+
166
+ <dt class="optional">
167
+ seed
168
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-seed" target="_blank"><i
169
+ class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
170
+ <span class="property-type">integer</span>
171
+ </dt>
172
+ <dd>
173
+ This feature is in Beta. If specified, the system will make a best
174
+ effort to sample deterministically, such that repeated requests with the
175
+ same seed and parameters should return the same result.
176
+ </dd>
177
+
178
+ <dt class="optional">
179
+ service_tier
180
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-service_tier"
181
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
182
+ <span class="property-type">string or null</span>
183
+ </dt>
184
+ <dd>
185
+ Specifies the latency tier to use for processing the request.
186
+ </dd>
187
+
188
+ <dt class="optional">
189
+ stop
190
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-stop" target="_blank"><i
191
+ class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
192
+ <span class="property-type">string | array</span>
193
+ </dt>
194
+ <dd>
195
+ Up to 4 sequences where the API will stop generating further tokens.
196
+ </dd>
197
+
198
+ <dt class="optional">
199
+ stream
200
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-stream"
201
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
202
+ <span class="property-type">boolean</span>
203
+ </dt>
204
+ <dd>If set, partial message deltas will be sent, like in ChatGPT.</dd>
205
+
206
+ <dt class="optional">
207
+ stream_options
208
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-stream_options"
209
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
210
+ <span class="property-type">object</span>
211
+ </dt>
212
+ <dd>Options for streaming response. Only set this when you set ```stream: true```.</dd>
213
+
214
+ <dt class="optional">
215
+ temperature
216
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-temperature"
217
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
218
+ <span class="property-type">number</span>
219
+ </dt>
220
+ <dd>What sampling temperature to use, between 0 and 2.</dd>
221
+
222
+ <dt class="optional">
223
+ top_p
224
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-top_p"
225
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
226
+ <span class="property-type">number</span>
227
+ </dt>
228
+ <dd>
229
+ An alternative to sampling with temperature, called nucleus sampling,
230
+ where the model considers the results of the tokens with top_p
231
+ probability mass.
232
+ </dd>
233
+
234
+ <dt class="optional">
235
+ tools
236
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools"
237
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
238
+ <span class="property-type">array</span>
239
+ </dt>
240
+ <dd>A list of tools the model may call.</dd>
241
+
242
+ <dt class="optional">
243
+ tool_choice
244
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice"
245
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
246
+ <span class="property-type">string | object</span>
247
+ </dt>
248
+ <dd>Whether to enable parallel function calling during tool use.</dd>
249
+
250
+ <dt class="optional">
251
+ parallel_tool_calls
252
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-parallel_tool_calls"
253
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
254
+ <span class="property-type">string | object</span>
255
+ </dt>
256
+ <dd>Whether to enable parallel function calling during tool use.</dd>
257
+
258
+ <dt class="optional">
259
+ user
260
+ <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-user" target="_blank"><i
261
+ class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
262
+ <span class="property-type">string</span>
263
+ </dt>
264
+ <dd>
265
+ A unique identifier representing your end-user, which can help OpenAI to
266
+ monitor and detect abuse.
267
+ </dd>
268
+
269
+ </dl>
270
+
271
+
272
+ <h4 style="font-weight: bolder;"> ⋙ Get Chat Completion</h4>
273
+ <p>
274
+ Get a stored chat completion.
275
+ <a href="https://platform.openai.com/docs/api-reference/chat/get" target="_blank">Full documentation.</a>
276
+ </p>
277
+ <dl class="message-properties">
278
+ <h4>msg.payload Properties</h4>
279
+
280
+ <dt>
281
+ completion_id
282
+ <a href="https://platform.openai.com/docs/api-reference/chat/get#chat-get-completion_id"
283
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
284
+ <span class="property-type">string</span>
285
+ </dt>
286
+ <dd>The ID of the chat completion to retrieve.</dd>
287
+ </dl>
288
+
289
+ <!-- Begin Get Chat Messages -->
290
+ <h4 style="font-weight: bolder;"> ⋙ Get Chat Messages</h4>
291
+ <p>
292
+ Get the messages in a stored chat completion.
293
+ <a href="https://platform.openai.com/docs/api-reference/chat/getMessages" target="_blank">Full
294
+ documentation.</a>
295
+ </p>
296
+ <dl class="message-properties">
297
+ <h4>msg.payload Properties</h4>
298
+
299
+ <dt>
300
+ completion_id
301
+ <a href="https://platform.openai.com/docs/api-reference/chat/getMessages#chat-getmessages-completion_id"
302
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
303
+ <span class="property-type">string</span>
304
+ </dt>
305
+ <dd>The ID of the chat completion to retrieve messages from.</dd>
306
+
307
+ <dt class="optional">
308
+ after
309
+ <a href="https://platform.openai.com/docs/api-reference/chat/getMessages#chat-getmessages-afterf"
310
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
311
+ <span class="property-type">string</span>
312
+ </dt>
313
+ <dd>Identifier for the last message from the previous pagination request.</dd>
314
+
315
+ <dt class="optional">
316
+ limit
317
+ <a href="https://platform.openai.com/docs/api-reference/chat/getMessages#chat-getmessages-limit"
318
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
319
+ <span class="property-type">integer</span>
320
+ </dt>
321
+ <dd>Number of messages to retrieve.</dd>
322
+
323
+ <dt class="optional">
324
+ order
325
+ <a href="https://platform.openai.com/docs/api-reference/chat/getMessages#chat-getmessages-order"
326
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
327
+ <span class="property-type">string</span>
328
+ </dt>
329
+ <dd>Sort order for messages by timestamp.</dd>
330
+ </dl>
331
+ <!-- END Get Chat Messages -->
332
+
333
+ <!-- Begin List Chat Completions -->
334
+ <dl>
335
+ <h4 style="font-weight: bolder;"> ⋙ List Chat Completions</h4>
336
+ <p>
337
+ List stored chat completions.
338
+ <a href="https://platform.openai.com/docs/api-reference/chat/list" target="_blank">Full
339
+ documentation.</a>
340
+ </p>
341
+ <dl class="message-properties">
342
+ <h4>msg.payload Properties</h4>
343
+
344
+ <dt class="optional">
345
+ model
346
+ <a href="https://platform.openai.com/docs/api-reference/chat/list#chat-list-model"
347
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
348
+ <span class="property-type">string</span>
349
+ </dt>
350
+ <dd>The model used to generate the chat completions.</dd>
351
+
352
+ <dt class="optional">
353
+ metadata
354
+ <a href="https://platform.openai.com/docs/api-reference/chat/list#chat-list-metadata"
355
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
356
+ <span class="property-type">object</span>
357
+ </dt>
358
+ <dd>A list of metadata keys to filter the chat completions by.</dd>
359
+
360
+ <dt class="optional">
361
+ after
362
+ <a href="https://platform.openai.com/docs/api-reference/chat/getMessages#chat-getmessages-limit"
363
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
364
+ <span class="property-type">string</span>
365
+ </dt>
366
+ <dd>Identifier for the last chat completion from the previous pagination request.</dd>
367
+
368
+ <dt class="optional">
369
+ limit
370
+ <a href="https://platform.openai.com/docs/api-reference/chat/list#chat-list-limit"
371
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
372
+ <span class="property-type">integer</span>
373
+ </dt>
374
+ <dd>Number of chat completions to retrieve.</dd>
375
+
376
+ <dt class="optional">
377
+ order
378
+ <a href="https://platform.openai.com/docs/api-reference/chat/list#chat-list-order"
379
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
380
+ <span class="property-type">string</span>
381
+ </dt>
382
+ <dd>Sort order for chat completions by timestamp.</dd>
383
+ </dl>
384
+ <!-- END List Chat Completions -->
385
+
386
+ <!-- Begin Update Chat Completions -->
387
+ <dl>
388
+ <h4 style="font-weight: bolder;"> ⋙ Update Chat Completion</h4>
389
+ <p>
390
+ Modify a stored chat completion.
391
+ <a href="https://platform.openai.com/docs/api-reference/chat/update" target="_blank">Full
392
+ documentation.</a>
393
+ </p>
394
+ <dl class="message-properties">
395
+ <h4>msg.payload Properties</h4>
396
+
397
+ <dt>
398
+ completion_id
399
+ <a href="https://platform.openai.com/docs/api-reference/chat/update#chat-update-completion_id"
400
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
401
+ <span class="property-type">string</span>
402
+ </dt>
403
+ <dd>The ID of the chat completion to update.</dd>
404
+
405
+ <dt>
406
+ metadata
407
+ <a href="https://platform.openai.com/docs/api-reference/chat/getMessages#chat-getmessages-limit"
408
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
409
+ <span class="property-type">object</span>
410
+ </dt>
411
+ <dd>Set of 16 key-value pairs that can be attached to an object.</dd>
412
+ </dl>
413
+ <!-- END Update Chat Completion -->
414
+
415
+ <!-- Begin Delete Chat Completion -->
416
+ <dl>
417
+ <h4 style="font-weight: bolder;"> ⋙ Delete Chat Completion</h4>
418
+ <p>
419
+ Delete a stored chat completion.
420
+ <a href="https://platform.openai.com/docs/api-reference/chat/delete" target="_blank">Full
421
+ documentation.</a>
422
+ </p>
423
+ <dl class="message-properties">
424
+ <h4>msg.payload Properties</h4>
425
+
426
+ <dt>
427
+ completion_id
428
+ <a href="https://platform.openai.com/docs/api-reference/chat/delete#chat-delete-completion_id"
429
+ target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
430
+ <span class="property-type">string</span>
431
+ </dt>
432
+ <dd>The ID of the chat completion to delete.</dd>
433
+ </dl>
434
+ <!-- END Delete Chat Completion -->
435
+ </details>
436
+ </section>
@@ -0,0 +1,82 @@
1
+ const OpenAI = require("openai").OpenAI;
2
+
3
+ async function createChatCompletion(parameters) {
4
+ const { _node, ...params } = parameters;
5
+ const openai = new OpenAI(this.clientParams);
6
+ const response = await openai.chat.completions.create(params.payload);
7
+
8
+ if (params.payload.stream) {
9
+ _node.status({
10
+ fill: "green",
11
+ shape: "dot",
12
+ text: "OpenaiApi.status.streaming",
13
+ });
14
+ for await (const chunk of response) {
15
+ if (typeof chunk === "object") {
16
+ const newMsg = { ...parameters.msg, payload: chunk };
17
+ _node.send(newMsg);
18
+ }
19
+ }
20
+ _node.status({});
21
+ } else {
22
+ return response;
23
+ }
24
+ }
25
+
26
+ async function getChatCompletion(parameters) {
27
+ const openai = new OpenAI(this.clientParams);
28
+ const { completion_id, ...options } = parameters.payload;
29
+
30
+ const response = await openai.chat.completions.retrieve(
31
+ completion_id,
32
+ options
33
+ );
34
+
35
+ return response;
36
+ }
37
+
38
+ async function getChatMessages(parameters) {
39
+ const openai = new OpenAI(this.clientParams);
40
+ const { completion_id, ...options } = parameters.payload;
41
+
42
+ const response = await openai.chat.completions.messages.list(
43
+ completion_id,
44
+ options
45
+ );
46
+
47
+ return response.data;
48
+ }
49
+
50
+ async function listChatCompletions(parameters) {
51
+ const openai = new OpenAI(this.clientParams);
52
+ const response = await openai.chat.completions.list(parameters.payload);
53
+
54
+ return response.data;
55
+ }
56
+
57
+ async function updateChatCompletion(parameters) {
58
+ const openai = new OpenAI(this.clientParams);
59
+ const { completion_id, ...body } = parameters.payload;
60
+
61
+ const response = await openai.chat.completions.update(completion_id, body);
62
+
63
+ return response;
64
+ }
65
+
66
+ async function deleteChatCompletion(parameters) {
67
+ const openai = new OpenAI(this.clientParams);
68
+ const { completion_id, ...options } = parameters.payload;
69
+
70
+ const response = await openai.chat.completions.del(completion_id, options);
71
+
72
+ return response;
73
+ }
74
+
75
+ module.exports = {
76
+ createChatCompletion,
77
+ getChatCompletion,
78
+ getChatMessages,
79
+ listChatCompletions,
80
+ updateChatCompletion,
81
+ deleteChatCompletion,
82
+ };
@@ -0,0 +1,30 @@
1
+ <optgroup style="font-style: normal;" label="💬 Chat">
2
+ <option
3
+ value="createChatCompletion"
4
+ data-i18n="OpenaiApi.parameters.createChatCompletion"
5
+ ></option>
6
+ <option
7
+ value="getChatCompletion"
8
+ data-i18n="OpenaiApi.parameters.getChatCompletion"
9
+ ></option>
10
+ <option
11
+ value="getChatMessages"
12
+ data-i18n="OpenaiApi.parameters.getChatMessages"
13
+ ></option>
14
+
15
+ <option
16
+ value="listChatCompletions"
17
+ data-i18n="OpenaiApi.parameters.listChatCompletions"
18
+ ></option>
19
+
20
+ <option
21
+ value="updateChatCompletion"
22
+ data-i18n="OpenaiApi.parameters.updateChatCompletion"
23
+ ></option>
24
+
25
+ <option
26
+ value="deleteChatCompletion"
27
+ data-i18n="OpenaiApi.parameters.deleteChatCompletion"
28
+ ></option>
29
+
30
+ </optgroup>