@inductiv/node-red-openai-api 0.7.0 → 0.8.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 +3 -3
- package/lib.js +63 -337
- package/node.html +139 -4
- package/node.js +9 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
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.8.0
|
|
13
13
|
|
|
14
|
-
-
|
|
14
|
+
- **Bug Fix**: Fixed an issue introduced in v. 0.7.0 that caused the `createChatCompletion` endpoint to return duplicate messages.
|
|
15
|
+
- **Enhancement**: Bumped the OpenAI API package dependency to version 4.36.0. Updated the node's documentation accordingly.
|
|
15
16
|
|
|
16
17
|
Please report any issues [here on Github](https://github.com/allanbunch/node-red-openai-api/issues).
|
|
17
18
|
|
|
@@ -53,7 +54,6 @@ This package's configuration node is now named "Service Host" to serve as a more
|
|
|
53
54
|
- [Installation](#installation)
|
|
54
55
|
- [Usage](#usage)
|
|
55
56
|
- [License](#license)
|
|
56
|
-
- [Acknowledgements](#acknowledgements)
|
|
57
57
|
|
|
58
58
|
## Installation
|
|
59
59
|
|
package/lib.js
CHANGED
|
@@ -5,17 +5,19 @@ let OpenaiApi = (function () {
|
|
|
5
5
|
const OpenAI = require("openai").OpenAI;
|
|
6
6
|
|
|
7
7
|
class OpenaiApi {
|
|
8
|
+
constructor(apiKey, baseURL, organization) {
|
|
9
|
+
this.clientParams = {
|
|
10
|
+
apiKey: apiKey,
|
|
11
|
+
baseURL: baseURL,
|
|
12
|
+
organization: organization
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
async createChatCompletion(parameters) {
|
|
9
17
|
let node = parameters._node;
|
|
10
18
|
delete parameters._node;
|
|
11
19
|
|
|
12
|
-
const
|
|
13
|
-
apiKey: parameters.apiKey,
|
|
14
|
-
baseURL: parameters.apiBase,
|
|
15
|
-
organization: parameters.organization,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const openai = new OpenAI(clientParams);
|
|
20
|
+
const openai = new OpenAI(this.clientParams);
|
|
19
21
|
const response = await openai.chat.completions.create({
|
|
20
22
|
...parameters.msg.payload,
|
|
21
23
|
});
|
|
@@ -28,9 +30,11 @@ let OpenaiApi = (function () {
|
|
|
28
30
|
});
|
|
29
31
|
for await (const chunk of response) {
|
|
30
32
|
if (typeof chunk === "object") {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
let {_msgid, ...newMsg} = parameters.msg;
|
|
35
|
+
newMsg.payload = chunk;
|
|
36
|
+
|
|
37
|
+
node.send(newMsg);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
node.status({});
|
|
@@ -40,13 +44,7 @@ let OpenaiApi = (function () {
|
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
async createImage(parameters) {
|
|
43
|
-
const
|
|
44
|
-
apiKey: parameters.apiKey,
|
|
45
|
-
baseURL: parameters.apiBase,
|
|
46
|
-
organization: parameters.organization,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const openai = new OpenAI(clientParams);
|
|
47
|
+
const openai = new OpenAI(this.clientParams);
|
|
50
48
|
const response = await openai.images.generate({
|
|
51
49
|
...parameters.msg.payload,
|
|
52
50
|
});
|
|
@@ -55,12 +53,7 @@ let OpenaiApi = (function () {
|
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
async createImageEdit(parameters) {
|
|
58
|
-
const
|
|
59
|
-
apiKey: parameters.apiKey,
|
|
60
|
-
baseURL: parameters.apiBase,
|
|
61
|
-
organization: parameters.organization,
|
|
62
|
-
};
|
|
63
|
-
const openai = new OpenAI(clientParams);
|
|
56
|
+
const openai = new OpenAI(this.clientParams);
|
|
64
57
|
|
|
65
58
|
parameters.msg.payload.image = fs.createReadStream(
|
|
66
59
|
parameters.msg.payload.image,
|
|
@@ -79,12 +72,7 @@ let OpenaiApi = (function () {
|
|
|
79
72
|
}
|
|
80
73
|
|
|
81
74
|
async createImageVariation(parameters) {
|
|
82
|
-
const
|
|
83
|
-
apiKey: parameters.apiKey,
|
|
84
|
-
baseURL: parameters.apiBase,
|
|
85
|
-
organization: parameters.organization,
|
|
86
|
-
};
|
|
87
|
-
const openai = new OpenAI(clientParams);
|
|
75
|
+
const openai = new OpenAI(this.clientParams);
|
|
88
76
|
|
|
89
77
|
parameters.msg.payload.image = fs.createReadStream(
|
|
90
78
|
parameters.msg.payload.image,
|
|
@@ -97,12 +85,7 @@ let OpenaiApi = (function () {
|
|
|
97
85
|
}
|
|
98
86
|
|
|
99
87
|
async createEmbedding(parameters) {
|
|
100
|
-
const
|
|
101
|
-
apiKey: parameters.apiKey,
|
|
102
|
-
baseURL: parameters.apiBase,
|
|
103
|
-
organization: parameters.organization,
|
|
104
|
-
};
|
|
105
|
-
const openai = new OpenAI(clientParams);
|
|
88
|
+
const openai = new OpenAI(this.clientParams);
|
|
106
89
|
|
|
107
90
|
const response = await openai.embeddings.create({
|
|
108
91
|
...parameters.msg.payload,
|
|
@@ -112,12 +95,7 @@ let OpenaiApi = (function () {
|
|
|
112
95
|
}
|
|
113
96
|
|
|
114
97
|
async createSpeech(parameters) {
|
|
115
|
-
const
|
|
116
|
-
apiKey: parameters.apiKey,
|
|
117
|
-
baseURL: parameters.apiBase,
|
|
118
|
-
organization: parameters.organization,
|
|
119
|
-
};
|
|
120
|
-
const openai = new OpenAI(clientParams);
|
|
98
|
+
const openai = new OpenAI(this.clientParams);
|
|
121
99
|
|
|
122
100
|
const audio = await openai.audio.speech.create({
|
|
123
101
|
...parameters.msg.payload,
|
|
@@ -128,12 +106,7 @@ let OpenaiApi = (function () {
|
|
|
128
106
|
}
|
|
129
107
|
|
|
130
108
|
async createTranscription(parameters) {
|
|
131
|
-
const
|
|
132
|
-
apiKey: parameters.apiKey,
|
|
133
|
-
baseURL: parameters.apiBase,
|
|
134
|
-
organization: parameters.organization,
|
|
135
|
-
};
|
|
136
|
-
const openai = new OpenAI(clientParams);
|
|
109
|
+
const openai = new OpenAI(this.clientParams);
|
|
137
110
|
|
|
138
111
|
parameters.msg.payload.file = fs.createReadStream(
|
|
139
112
|
parameters.msg.payload.file,
|
|
@@ -147,12 +120,7 @@ let OpenaiApi = (function () {
|
|
|
147
120
|
}
|
|
148
121
|
|
|
149
122
|
async createTranslation(parameters) {
|
|
150
|
-
const
|
|
151
|
-
apiKey: parameters.apiKey,
|
|
152
|
-
baseURL: parameters.apiBase,
|
|
153
|
-
organization: parameters.organization,
|
|
154
|
-
};
|
|
155
|
-
const openai = new OpenAI(clientParams);
|
|
123
|
+
const openai = new OpenAI(this.clientParams);
|
|
156
124
|
|
|
157
125
|
parameters.msg.payload.file = fs.createReadStream(
|
|
158
126
|
parameters.msg.payload.file,
|
|
@@ -165,12 +133,7 @@ let OpenaiApi = (function () {
|
|
|
165
133
|
}
|
|
166
134
|
|
|
167
135
|
async listFiles(parameters) {
|
|
168
|
-
const
|
|
169
|
-
apiKey: parameters.apiKey,
|
|
170
|
-
baseURL: parameters.apiBase,
|
|
171
|
-
organization: parameters.organization,
|
|
172
|
-
};
|
|
173
|
-
const openai = new OpenAI(clientParams);
|
|
136
|
+
const openai = new OpenAI(this.clientParams);
|
|
174
137
|
|
|
175
138
|
const list = await openai.files.list({
|
|
176
139
|
...parameters.msg.payload,
|
|
@@ -185,12 +148,7 @@ let OpenaiApi = (function () {
|
|
|
185
148
|
}
|
|
186
149
|
|
|
187
150
|
async createFile(parameters) {
|
|
188
|
-
const
|
|
189
|
-
apiKey: parameters.apiKey,
|
|
190
|
-
baseURL: parameters.apiBase,
|
|
191
|
-
organization: parameters.organization,
|
|
192
|
-
};
|
|
193
|
-
const openai = new OpenAI(clientParams);
|
|
151
|
+
const openai = new OpenAI(this.clientParams);
|
|
194
152
|
|
|
195
153
|
parameters.msg.payload.file = fs.createReadStream(
|
|
196
154
|
parameters.msg.payload.file,
|
|
@@ -203,12 +161,7 @@ let OpenaiApi = (function () {
|
|
|
203
161
|
}
|
|
204
162
|
|
|
205
163
|
async deleteFile(parameters) {
|
|
206
|
-
const
|
|
207
|
-
apiKey: parameters.apiKey,
|
|
208
|
-
baseURL: parameters.apiBase,
|
|
209
|
-
organization: parameters.organization,
|
|
210
|
-
};
|
|
211
|
-
const openai = new OpenAI(clientParams);
|
|
164
|
+
const openai = new OpenAI(this.clientParams);
|
|
212
165
|
|
|
213
166
|
const response = await openai.files.del({
|
|
214
167
|
...parameters.msg.payload,
|
|
@@ -218,12 +171,7 @@ let OpenaiApi = (function () {
|
|
|
218
171
|
}
|
|
219
172
|
|
|
220
173
|
async retrieveFile(parameters) {
|
|
221
|
-
const
|
|
222
|
-
apiKey: parameters.apiKey,
|
|
223
|
-
baseURL: parameters.apiBase,
|
|
224
|
-
organization: parameters.organization,
|
|
225
|
-
};
|
|
226
|
-
const openai = new OpenAI(clientParams);
|
|
174
|
+
const openai = new OpenAI(this.clientParams);
|
|
227
175
|
|
|
228
176
|
const file_id = parameters.msg.payload.file_id;
|
|
229
177
|
delete parameters.msg.payload.file_id;
|
|
@@ -236,12 +184,7 @@ let OpenaiApi = (function () {
|
|
|
236
184
|
}
|
|
237
185
|
|
|
238
186
|
async downloadFile(parameters) {
|
|
239
|
-
const
|
|
240
|
-
apiKey: parameters.apiKey,
|
|
241
|
-
baseURL: parameters.apiBase,
|
|
242
|
-
organization: parameters.organization,
|
|
243
|
-
};
|
|
244
|
-
const openai = new OpenAI(clientParams);
|
|
187
|
+
const openai = new OpenAI(this.clientParams);
|
|
245
188
|
|
|
246
189
|
const file_id = parameters.msg.payload.file_id;
|
|
247
190
|
delete parameters.msg.payload.file_id;
|
|
@@ -254,12 +197,7 @@ let OpenaiApi = (function () {
|
|
|
254
197
|
}
|
|
255
198
|
|
|
256
199
|
async createFineTuningJob(parameters) {
|
|
257
|
-
const
|
|
258
|
-
apiKey: parameters.apiKey,
|
|
259
|
-
baseURL: parameters.apiBase,
|
|
260
|
-
organization: parameters.organization,
|
|
261
|
-
};
|
|
262
|
-
const openai = new OpenAI(clientParams);
|
|
200
|
+
const openai = new OpenAI(this.clientParams);
|
|
263
201
|
|
|
264
202
|
const response = await openai.fineTuning.jobs.create({
|
|
265
203
|
...parameters.msg.payload,
|
|
@@ -269,12 +207,7 @@ let OpenaiApi = (function () {
|
|
|
269
207
|
}
|
|
270
208
|
|
|
271
209
|
async listPaginatedFineTuningJobs(parameters) {
|
|
272
|
-
const
|
|
273
|
-
apiKey: parameters.apiKey,
|
|
274
|
-
baseURL: parameters.apiBase,
|
|
275
|
-
organization: parameters.organization,
|
|
276
|
-
};
|
|
277
|
-
const openai = new OpenAI(clientParams);
|
|
210
|
+
const openai = new OpenAI(this.clientParams);
|
|
278
211
|
|
|
279
212
|
const list = await openai.fineTuning.jobs.list({
|
|
280
213
|
...parameters.msg.payload,
|
|
@@ -289,12 +222,7 @@ let OpenaiApi = (function () {
|
|
|
289
222
|
}
|
|
290
223
|
|
|
291
224
|
async retrieveFineTuningJob(parameters) {
|
|
292
|
-
const
|
|
293
|
-
apiKey: parameters.apiKey,
|
|
294
|
-
baseURL: parameters.apiBase,
|
|
295
|
-
organization: parameters.organization,
|
|
296
|
-
};
|
|
297
|
-
const openai = new OpenAI(clientParams);
|
|
225
|
+
const openai = new OpenAI(this.clientParams);
|
|
298
226
|
|
|
299
227
|
const response = await openai.fineTuning.jobs.retrieve(
|
|
300
228
|
parameters.msg.payload.fine_tuning_job_id,
|
|
@@ -304,12 +232,7 @@ let OpenaiApi = (function () {
|
|
|
304
232
|
}
|
|
305
233
|
|
|
306
234
|
async listFineTuningEvents(parameters) {
|
|
307
|
-
const
|
|
308
|
-
apiKey: parameters.apiKey,
|
|
309
|
-
baseURL: parameters.apiBase,
|
|
310
|
-
organization: parameters.organization,
|
|
311
|
-
};
|
|
312
|
-
const openai = new OpenAI(clientParams);
|
|
235
|
+
const openai = new OpenAI(this.clientParams);
|
|
313
236
|
|
|
314
237
|
let response = [];
|
|
315
238
|
const list = await openai.fineTuning.jobs.listEvents(
|
|
@@ -322,12 +245,7 @@ let OpenaiApi = (function () {
|
|
|
322
245
|
}
|
|
323
246
|
|
|
324
247
|
async cancelFineTuningJob(parameters) {
|
|
325
|
-
const
|
|
326
|
-
apiKey: parameters.apiKey,
|
|
327
|
-
baseURL: parameters.apiBase,
|
|
328
|
-
organization: parameters.organization,
|
|
329
|
-
};
|
|
330
|
-
const openai = new OpenAI(clientParams);
|
|
248
|
+
const openai = new OpenAI(this.clientParams);
|
|
331
249
|
|
|
332
250
|
const response = await openai.fineTuning.jobs.cancel(
|
|
333
251
|
parameters.msg.payload.fine_tuning_job_id,
|
|
@@ -337,26 +255,14 @@ let OpenaiApi = (function () {
|
|
|
337
255
|
}
|
|
338
256
|
|
|
339
257
|
async listModels(parameters) {
|
|
340
|
-
const
|
|
341
|
-
apiKey: parameters.apiKey,
|
|
342
|
-
baseURL: parameters.apiBase,
|
|
343
|
-
organization: parameters.organization,
|
|
344
|
-
};
|
|
345
|
-
const openai = new OpenAI(clientParams);
|
|
346
|
-
|
|
258
|
+
const openai = new OpenAI(this.clientParams);
|
|
347
259
|
const response = await openai.models.list();
|
|
348
260
|
|
|
349
261
|
return response.body;
|
|
350
262
|
}
|
|
351
263
|
|
|
352
264
|
async retrieveModel(parameters) {
|
|
353
|
-
const
|
|
354
|
-
apiKey: parameters.apiKey,
|
|
355
|
-
baseURL: parameters.apiBase,
|
|
356
|
-
organization: parameters.organization,
|
|
357
|
-
};
|
|
358
|
-
const openai = new OpenAI(clientParams);
|
|
359
|
-
|
|
265
|
+
const openai = new OpenAI(this.clientParams);
|
|
360
266
|
const model = parameters.msg.payload.model;
|
|
361
267
|
const response = await openai.models.retrieve(model);
|
|
362
268
|
|
|
@@ -364,13 +270,7 @@ let OpenaiApi = (function () {
|
|
|
364
270
|
}
|
|
365
271
|
|
|
366
272
|
async deleteModel(parameters) {
|
|
367
|
-
const
|
|
368
|
-
apiKey: parameters.apiKey,
|
|
369
|
-
baseURL: parameters.apiBase,
|
|
370
|
-
organization: parameters.organization,
|
|
371
|
-
};
|
|
372
|
-
const openai = new OpenAI(clientParams);
|
|
373
|
-
|
|
273
|
+
const openai = new OpenAI(this.clientParams);
|
|
374
274
|
const model = parameters.msg.payload.model;
|
|
375
275
|
const response = await openai.models.del(model);
|
|
376
276
|
|
|
@@ -378,25 +278,13 @@ let OpenaiApi = (function () {
|
|
|
378
278
|
}
|
|
379
279
|
|
|
380
280
|
async createModeration(parameters) {
|
|
381
|
-
const
|
|
382
|
-
apiKey: parameters.apiKey,
|
|
383
|
-
baseURL: parameters.apiBase,
|
|
384
|
-
organization: parameters.organization,
|
|
385
|
-
};
|
|
386
|
-
const openai = new OpenAI(clientParams);
|
|
387
|
-
|
|
281
|
+
const openai = new OpenAI(this.clientParams);
|
|
388
282
|
const response = await openai.moderations.create(parameters.msg.payload);
|
|
389
283
|
return response;
|
|
390
284
|
}
|
|
391
285
|
|
|
392
286
|
async listAssistants(parameters) {
|
|
393
|
-
const
|
|
394
|
-
apiKey: parameters.apiKey,
|
|
395
|
-
baseURL: parameters.apiBase,
|
|
396
|
-
organization: parameters.organization,
|
|
397
|
-
};
|
|
398
|
-
const openai = new OpenAI(clientParams);
|
|
399
|
-
|
|
287
|
+
const openai = new OpenAI(this.clientParams);
|
|
400
288
|
const response = await openai.beta.assistants.list({
|
|
401
289
|
...parameters.msg.payload,
|
|
402
290
|
});
|
|
@@ -405,13 +293,7 @@ let OpenaiApi = (function () {
|
|
|
405
293
|
}
|
|
406
294
|
|
|
407
295
|
async createAssistant(parameters) {
|
|
408
|
-
const
|
|
409
|
-
apiKey: parameters.apiKey,
|
|
410
|
-
baseURL: parameters.apiBase,
|
|
411
|
-
organization: parameters.organization,
|
|
412
|
-
};
|
|
413
|
-
const openai = new OpenAI(clientParams);
|
|
414
|
-
|
|
296
|
+
const openai = new OpenAI(this.clientParams);
|
|
415
297
|
const response = await openai.beta.assistants.create({
|
|
416
298
|
...parameters.msg.payload,
|
|
417
299
|
});
|
|
@@ -420,13 +302,7 @@ let OpenaiApi = (function () {
|
|
|
420
302
|
}
|
|
421
303
|
|
|
422
304
|
async getAssistant(parameters) {
|
|
423
|
-
const
|
|
424
|
-
apiKey: parameters.apiKey,
|
|
425
|
-
baseURL: parameters.apiBase,
|
|
426
|
-
organization: parameters.organization,
|
|
427
|
-
};
|
|
428
|
-
const openai = new OpenAI(clientParams);
|
|
429
|
-
|
|
305
|
+
const openai = new OpenAI(this.clientParams);
|
|
430
306
|
const id = parameters.msg.payload.assistant_id;
|
|
431
307
|
const response = await openai.beta.assistants.retrieve(id);
|
|
432
308
|
|
|
@@ -434,13 +310,7 @@ let OpenaiApi = (function () {
|
|
|
434
310
|
}
|
|
435
311
|
|
|
436
312
|
async modifyAssistant(parameters) {
|
|
437
|
-
const
|
|
438
|
-
apiKey: parameters.apiKey,
|
|
439
|
-
baseURL: parameters.apiBase,
|
|
440
|
-
organization: parameters.organization,
|
|
441
|
-
};
|
|
442
|
-
const openai = new OpenAI(clientParams);
|
|
443
|
-
|
|
313
|
+
const openai = new OpenAI(this.clientParams);
|
|
444
314
|
const id = parameters.msg.payload.assistant_id;
|
|
445
315
|
delete parameters.msg.payload.assistant_id;
|
|
446
316
|
|
|
@@ -452,13 +322,7 @@ let OpenaiApi = (function () {
|
|
|
452
322
|
}
|
|
453
323
|
|
|
454
324
|
async deleteAssistant(parameters) {
|
|
455
|
-
const
|
|
456
|
-
apiKey: parameters.apiKey,
|
|
457
|
-
baseURL: parameters.apiBase,
|
|
458
|
-
organization: parameters.organization,
|
|
459
|
-
};
|
|
460
|
-
const openai = new OpenAI(clientParams);
|
|
461
|
-
|
|
325
|
+
const openai = new OpenAI(this.clientParams);
|
|
462
326
|
const id = parameters.msg.payload.assistant_id;
|
|
463
327
|
const response = await openai.beta.assistants.del(id);
|
|
464
328
|
|
|
@@ -466,13 +330,7 @@ let OpenaiApi = (function () {
|
|
|
466
330
|
}
|
|
467
331
|
|
|
468
332
|
async createThread(parameters) {
|
|
469
|
-
const
|
|
470
|
-
apiKey: parameters.apiKey,
|
|
471
|
-
baseURL: parameters.apiBase,
|
|
472
|
-
organization: parameters.organization,
|
|
473
|
-
};
|
|
474
|
-
const openai = new OpenAI(clientParams);
|
|
475
|
-
|
|
333
|
+
const openai = new OpenAI(this.clientParams);
|
|
476
334
|
const response = await openai.beta.threads.create({
|
|
477
335
|
...parameters.msg.payload,
|
|
478
336
|
});
|
|
@@ -481,13 +339,7 @@ let OpenaiApi = (function () {
|
|
|
481
339
|
}
|
|
482
340
|
|
|
483
341
|
async getThread(parameters) {
|
|
484
|
-
const
|
|
485
|
-
apiKey: parameters.apiKey,
|
|
486
|
-
baseURL: parameters.apiBase,
|
|
487
|
-
organization: parameters.organization,
|
|
488
|
-
};
|
|
489
|
-
const openai = new OpenAI(clientParams);
|
|
490
|
-
|
|
342
|
+
const openai = new OpenAI(this.clientParams);
|
|
491
343
|
const id = parameters.msg.payload.thread_id;
|
|
492
344
|
const response = await openai.beta.threads.retrieve(id);
|
|
493
345
|
|
|
@@ -495,13 +347,7 @@ let OpenaiApi = (function () {
|
|
|
495
347
|
}
|
|
496
348
|
|
|
497
349
|
async modifyThread(parameters) {
|
|
498
|
-
const
|
|
499
|
-
apiKey: parameters.apiKey,
|
|
500
|
-
baseURL: parameters.apiBase,
|
|
501
|
-
organization: parameters.organization,
|
|
502
|
-
};
|
|
503
|
-
const openai = new OpenAI(clientParams);
|
|
504
|
-
|
|
350
|
+
const openai = new OpenAI(this.clientParams);
|
|
505
351
|
const id = parameters.msg.payload.thread_id;
|
|
506
352
|
delete parameters.msg.payload.thread_id;
|
|
507
353
|
|
|
@@ -513,13 +359,7 @@ let OpenaiApi = (function () {
|
|
|
513
359
|
}
|
|
514
360
|
|
|
515
361
|
async deleteThread(parameters) {
|
|
516
|
-
const
|
|
517
|
-
apiKey: parameters.apiKey,
|
|
518
|
-
baseURL: parameters.apiBase,
|
|
519
|
-
organization: parameters.organization,
|
|
520
|
-
};
|
|
521
|
-
const openai = new OpenAI(clientParams);
|
|
522
|
-
|
|
362
|
+
const openai = new OpenAI(this.clientParams);
|
|
523
363
|
const id = parameters.msg.payload.thread_id;
|
|
524
364
|
const response = await openai.beta.threads.del(id);
|
|
525
365
|
|
|
@@ -527,13 +367,7 @@ let OpenaiApi = (function () {
|
|
|
527
367
|
}
|
|
528
368
|
|
|
529
369
|
async listMessages(parameters) {
|
|
530
|
-
const
|
|
531
|
-
apiKey: parameters.apiKey,
|
|
532
|
-
baseURL: parameters.apiBase,
|
|
533
|
-
organization: parameters.organization,
|
|
534
|
-
};
|
|
535
|
-
const openai = new OpenAI(clientParams);
|
|
536
|
-
|
|
370
|
+
const openai = new OpenAI(this.clientParams);
|
|
537
371
|
const id = parameters.msg.payload.thread_id;
|
|
538
372
|
const response = await openai.beta.threads.messages.list(id);
|
|
539
373
|
|
|
@@ -541,13 +375,7 @@ let OpenaiApi = (function () {
|
|
|
541
375
|
}
|
|
542
376
|
|
|
543
377
|
async createMessage(parameters) {
|
|
544
|
-
const
|
|
545
|
-
apiKey: parameters.apiKey,
|
|
546
|
-
baseURL: parameters.apiBase,
|
|
547
|
-
organization: parameters.organization,
|
|
548
|
-
};
|
|
549
|
-
const openai = new OpenAI(clientParams);
|
|
550
|
-
|
|
378
|
+
const openai = new OpenAI(this.clientParams);
|
|
551
379
|
const thread_id = parameters.msg.payload.thread_id;
|
|
552
380
|
delete parameters.msg.payload.thread_id;
|
|
553
381
|
|
|
@@ -559,13 +387,7 @@ let OpenaiApi = (function () {
|
|
|
559
387
|
}
|
|
560
388
|
|
|
561
389
|
async getMessage(parameters) {
|
|
562
|
-
const
|
|
563
|
-
apiKey: parameters.apiKey,
|
|
564
|
-
baseURL: parameters.apiBase,
|
|
565
|
-
organization: parameters.organization,
|
|
566
|
-
};
|
|
567
|
-
const openai = new OpenAI(clientParams);
|
|
568
|
-
|
|
390
|
+
const openai = new OpenAI(this.clientParams);
|
|
569
391
|
const thread_id = parameters.msg.payload.thread_id;
|
|
570
392
|
const message_id = parameters.msg.payload.message_id;
|
|
571
393
|
|
|
@@ -578,13 +400,7 @@ let OpenaiApi = (function () {
|
|
|
578
400
|
}
|
|
579
401
|
|
|
580
402
|
async modifyMessage(parameters) {
|
|
581
|
-
const
|
|
582
|
-
apiKey: parameters.apiKey,
|
|
583
|
-
baseURL: parameters.apiBase,
|
|
584
|
-
organization: parameters.organization,
|
|
585
|
-
};
|
|
586
|
-
const openai = new OpenAI(clientParams);
|
|
587
|
-
|
|
403
|
+
const openai = new OpenAI(this.clientParams);
|
|
588
404
|
const thread_id = parameters.msg.payload.thread_id;
|
|
589
405
|
const message_id = parameters.msg.payload.message_id;
|
|
590
406
|
delete parameters.msg.payload.thread_id;
|
|
@@ -602,13 +418,7 @@ let OpenaiApi = (function () {
|
|
|
602
418
|
}
|
|
603
419
|
|
|
604
420
|
async createThreadAndRun(parameters) {
|
|
605
|
-
const
|
|
606
|
-
apiKey: parameters.apiKey,
|
|
607
|
-
baseURL: parameters.apiBase,
|
|
608
|
-
organization: parameters.organization,
|
|
609
|
-
};
|
|
610
|
-
const openai = new OpenAI(clientParams);
|
|
611
|
-
|
|
421
|
+
const openai = new OpenAI(this.clientParams);
|
|
612
422
|
const response = await openai.beta.threads.createAndRun({
|
|
613
423
|
...parameters.msg.payload,
|
|
614
424
|
});
|
|
@@ -617,13 +427,7 @@ let OpenaiApi = (function () {
|
|
|
617
427
|
}
|
|
618
428
|
|
|
619
429
|
async listRuns(parameters) {
|
|
620
|
-
const
|
|
621
|
-
apiKey: parameters.apiKey,
|
|
622
|
-
baseURL: parameters.apiBase,
|
|
623
|
-
organization: parameters.organization,
|
|
624
|
-
};
|
|
625
|
-
const openai = new OpenAI(clientParams);
|
|
626
|
-
|
|
430
|
+
const openai = new OpenAI(this.clientParams);
|
|
627
431
|
const thred_id = parameters.msg.payload.thread_id;
|
|
628
432
|
delete parameters.msg.payload.thread_id;
|
|
629
433
|
|
|
@@ -635,13 +439,7 @@ let OpenaiApi = (function () {
|
|
|
635
439
|
}
|
|
636
440
|
|
|
637
441
|
async createRun(parameters) {
|
|
638
|
-
const
|
|
639
|
-
apiKey: parameters.apiKey,
|
|
640
|
-
baseURL: parameters.apiBase,
|
|
641
|
-
organization: parameters.organization,
|
|
642
|
-
};
|
|
643
|
-
const openai = new OpenAI(clientParams);
|
|
644
|
-
|
|
442
|
+
const openai = new OpenAI(this.clientParams);
|
|
645
443
|
const thread_id = parameters.msg.payload.thread_id;
|
|
646
444
|
delete parameters.msg.payload.thread_id;
|
|
647
445
|
|
|
@@ -653,13 +451,7 @@ let OpenaiApi = (function () {
|
|
|
653
451
|
}
|
|
654
452
|
|
|
655
453
|
async getRun(parameters) {
|
|
656
|
-
const
|
|
657
|
-
apiKey: parameters.apiKey,
|
|
658
|
-
baseURL: parameters.apiBase,
|
|
659
|
-
organization: parameters.organization,
|
|
660
|
-
};
|
|
661
|
-
const openai = new OpenAI(clientParams);
|
|
662
|
-
|
|
454
|
+
const openai = new OpenAI(this.clientParams);
|
|
663
455
|
const thread_id = parameters.msg.payload.thread_id;
|
|
664
456
|
const run_id = parameters.msg.payload.run_id;
|
|
665
457
|
delete parameters.msg.payload.thread_id;
|
|
@@ -674,13 +466,7 @@ let OpenaiApi = (function () {
|
|
|
674
466
|
}
|
|
675
467
|
|
|
676
468
|
async modifyRun(parameters) {
|
|
677
|
-
const
|
|
678
|
-
apiKey: parameters.apiKey,
|
|
679
|
-
baseURL: parameters.apiBase,
|
|
680
|
-
organization: parameters.organization,
|
|
681
|
-
};
|
|
682
|
-
const openai = new OpenAI(clientParams);
|
|
683
|
-
|
|
469
|
+
const openai = new OpenAI(this.clientParams);
|
|
684
470
|
const thread_id = parameters.msg.payload.thread_id;
|
|
685
471
|
const run_id = parameters.msg.payload.run_id;
|
|
686
472
|
delete parameters.msg.payload.thread_id;
|
|
@@ -698,13 +484,7 @@ let OpenaiApi = (function () {
|
|
|
698
484
|
}
|
|
699
485
|
|
|
700
486
|
async submitToolOuputsToRun(parameters) {
|
|
701
|
-
const
|
|
702
|
-
apiKey: parameters.apiKey,
|
|
703
|
-
baseURL: parameters.apiBase,
|
|
704
|
-
organization: parameters.organization,
|
|
705
|
-
};
|
|
706
|
-
const openai = new OpenAI(clientParams);
|
|
707
|
-
|
|
487
|
+
const openai = new OpenAI(this.clientParams);
|
|
708
488
|
const thread_id = parameters.msg.payload.thread_id;
|
|
709
489
|
const run_id = parameters.msg.payload.run_id;
|
|
710
490
|
delete parameters.msg.payload.thread_id;
|
|
@@ -722,13 +502,7 @@ let OpenaiApi = (function () {
|
|
|
722
502
|
}
|
|
723
503
|
|
|
724
504
|
async cancelRun(parameters) {
|
|
725
|
-
const
|
|
726
|
-
apiKey: parameters.apiKey,
|
|
727
|
-
baseURL: parameters.apiBase,
|
|
728
|
-
organization: parameters.organization,
|
|
729
|
-
};
|
|
730
|
-
const openai = new OpenAI(clientParams);
|
|
731
|
-
|
|
505
|
+
const openai = new OpenAI(this.clientParams);
|
|
732
506
|
const thread_id = parameters.msg.payload.thread_id;
|
|
733
507
|
const run_id = parameters.msg.payload.run_id;
|
|
734
508
|
delete parameters.msg.payload.thread_id;
|
|
@@ -746,13 +520,7 @@ let OpenaiApi = (function () {
|
|
|
746
520
|
}
|
|
747
521
|
|
|
748
522
|
async listRunSteps(parameters) {
|
|
749
|
-
const
|
|
750
|
-
apiKey: parameters.apiKey,
|
|
751
|
-
baseURL: parameters.apiBase,
|
|
752
|
-
organization: parameters.organization,
|
|
753
|
-
};
|
|
754
|
-
const openai = new OpenAI(clientParams);
|
|
755
|
-
|
|
523
|
+
const openai = new OpenAI(this.clientParams);
|
|
756
524
|
const thread_id = parameters.msg.payload.thread_id;
|
|
757
525
|
const run_id = parameters.msg.payload.run_id;
|
|
758
526
|
delete parameters.msg.payload.thread_id;
|
|
@@ -770,13 +538,7 @@ let OpenaiApi = (function () {
|
|
|
770
538
|
}
|
|
771
539
|
|
|
772
540
|
async getRunStep(parameters) {
|
|
773
|
-
const
|
|
774
|
-
apiKey: parameters.apiKey,
|
|
775
|
-
baseURL: parameters.apiBase,
|
|
776
|
-
organization: parameters.organization,
|
|
777
|
-
};
|
|
778
|
-
const openai = new OpenAI(clientParams);
|
|
779
|
-
|
|
541
|
+
const openai = new OpenAI(this.clientParams);
|
|
780
542
|
const thread_id = parameters.msg.payload.thread_id;
|
|
781
543
|
const run_id = parameters.msg.payload.run_id;
|
|
782
544
|
const step_id = parameters.msg.payload.step_id;
|
|
@@ -791,13 +553,7 @@ let OpenaiApi = (function () {
|
|
|
791
553
|
}
|
|
792
554
|
|
|
793
555
|
async listAssistantFiles(parameters) {
|
|
794
|
-
const
|
|
795
|
-
apiKey: parameters.apiKey,
|
|
796
|
-
baseURL: parameters.apiBase,
|
|
797
|
-
organization: parameters.organization,
|
|
798
|
-
};
|
|
799
|
-
const openai = new OpenAI(clientParams);
|
|
800
|
-
|
|
556
|
+
const openai = new OpenAI(this.clientParams);
|
|
801
557
|
const assistant_id = parameters.msg.payload.assistant_id;
|
|
802
558
|
delete parameters.msg.payload.assistant_id;
|
|
803
559
|
|
|
@@ -809,13 +565,7 @@ let OpenaiApi = (function () {
|
|
|
809
565
|
}
|
|
810
566
|
|
|
811
567
|
async createAssistantFile(parameters) {
|
|
812
|
-
const
|
|
813
|
-
apiKey: parameters.apiKey,
|
|
814
|
-
baseURL: parameters.apiBase,
|
|
815
|
-
organization: parameters.organization,
|
|
816
|
-
};
|
|
817
|
-
const openai = new OpenAI(clientParams);
|
|
818
|
-
|
|
568
|
+
const openai = new OpenAI(this.clientParams);
|
|
819
569
|
const assistant_id = parameters.msg.payload.assistant_id;
|
|
820
570
|
delete parameters.msg.payload.assistant_id;
|
|
821
571
|
|
|
@@ -827,13 +577,7 @@ let OpenaiApi = (function () {
|
|
|
827
577
|
}
|
|
828
578
|
|
|
829
579
|
async getAssistantFile(parameters) {
|
|
830
|
-
const
|
|
831
|
-
apiKey: parameters.apiKey,
|
|
832
|
-
baseURL: parameters.apiBase,
|
|
833
|
-
organization: parameters.organization,
|
|
834
|
-
};
|
|
835
|
-
const openai = new OpenAI(clientParams);
|
|
836
|
-
|
|
580
|
+
const openai = new OpenAI(this.clientParams);
|
|
837
581
|
const assistant_id = parameters.msg.payload.assistant_id;
|
|
838
582
|
const file_id = parameters.msg.payload.file_id;
|
|
839
583
|
delete parameters.msg.payload.assistant_id;
|
|
@@ -851,13 +595,7 @@ let OpenaiApi = (function () {
|
|
|
851
595
|
}
|
|
852
596
|
|
|
853
597
|
async deleteAssistantFile(parameters) {
|
|
854
|
-
const
|
|
855
|
-
apiKey: parameters.apiKey,
|
|
856
|
-
baseURL: parameters.apiBase,
|
|
857
|
-
organization: parameters.organization,
|
|
858
|
-
};
|
|
859
|
-
const openai = new OpenAI(clientParams);
|
|
860
|
-
|
|
598
|
+
const openai = new OpenAI(this.clientParams);
|
|
861
599
|
const assistant_id = parameters.msg.payload.assistant_id;
|
|
862
600
|
const file_id = parameters.msg.payload.file_id;
|
|
863
601
|
delete parameters.msg.payload.assistant_id;
|
|
@@ -875,13 +613,7 @@ let OpenaiApi = (function () {
|
|
|
875
613
|
}
|
|
876
614
|
|
|
877
615
|
async listMessageFiles(parameters) {
|
|
878
|
-
const
|
|
879
|
-
apiKey: parameters.apiKey,
|
|
880
|
-
baseURL: parameters.apiBase,
|
|
881
|
-
organization: parameters.organization,
|
|
882
|
-
};
|
|
883
|
-
const openai = new OpenAI(clientParams);
|
|
884
|
-
|
|
616
|
+
const openai = new OpenAI(this.clientParams);
|
|
885
617
|
const thread_id = parameters.msg.payload.thread_id;
|
|
886
618
|
const message_id = parameters.msg.payload.message_id;
|
|
887
619
|
delete parameters.msg.payload.thread_id;
|
|
@@ -899,13 +631,7 @@ let OpenaiApi = (function () {
|
|
|
899
631
|
}
|
|
900
632
|
|
|
901
633
|
async getMessageFile(parameters) {
|
|
902
|
-
const
|
|
903
|
-
apiKey: parameters.apiKey,
|
|
904
|
-
baseURL: parameters.apiBase,
|
|
905
|
-
organization: parameters.organization,
|
|
906
|
-
};
|
|
907
|
-
const openai = new OpenAI(clientParams);
|
|
908
|
-
|
|
634
|
+
const openai = new OpenAI(this.clientParams);
|
|
909
635
|
const thread_id = parameters.msg.payload.thread_id;
|
|
910
636
|
const message_id = parameters.msg.payload.message_id;
|
|
911
637
|
const file_id = parameters.msg.payload.file_id;
|
package/node.html
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<!--TODO: Implement Batch API endpoints: https://github.com/openai/openai-node/blob/6f72e7ad3e4e151c9334f4449d1c3555255c2793/CHANGELOG.md#features-2 -->
|
|
2
|
+
|
|
1
3
|
<script type="text/javascript">
|
|
2
4
|
RED.nodes.registerType("OpenAI API", {
|
|
3
5
|
category: "AI",
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
$("#node-input-property").typedInput({
|
|
35
37
|
default: "msg",
|
|
36
38
|
value: "payload",
|
|
37
|
-
types:["msg", "flow", "global"],
|
|
39
|
+
types: ["msg", "flow", "global"],
|
|
38
40
|
typeField: "#node-input-propertyType"
|
|
39
41
|
})
|
|
40
42
|
}
|
|
@@ -852,6 +854,17 @@
|
|
|
852
854
|
<span class="property-type">number</span>
|
|
853
855
|
</dt>
|
|
854
856
|
<dd>The sampling temperature, between 0 and 1.</dd>
|
|
857
|
+
|
|
858
|
+
<dt class="optional">
|
|
859
|
+
timestamp_granularities
|
|
860
|
+
<a
|
|
861
|
+
href="https://platform.openai.com/docs/api-reference/audio/createTranscription#audio-createtranscription-timestamp_granularities"
|
|
862
|
+
target="_blank"
|
|
863
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
864
|
+
></a>
|
|
865
|
+
<span class="property-type">array</span>
|
|
866
|
+
</dt>
|
|
867
|
+
<dd>The timestamp granularities to populate for this transcription. <code>response_format</code> must be set to <code>verbose_json</code> to use timestamp granularities. Either or both of these options are supported: <code>word</code>, or <code>segment</code>.</dd>
|
|
855
868
|
</dl>
|
|
856
869
|
|
|
857
870
|
<h2>Create Translation</h2>
|
|
@@ -1831,6 +1844,18 @@
|
|
|
1831
1844
|
<span class="property-type">string</span>
|
|
1832
1845
|
</dt>
|
|
1833
1846
|
<dd>A cursor for use in pagination.</dd>
|
|
1847
|
+
|
|
1848
|
+
<dt class="optional">
|
|
1849
|
+
run_id
|
|
1850
|
+
<a
|
|
1851
|
+
href="https://platform.openai.com/docs/api-reference/messages/listMessages#messages-listmessages-run_id"
|
|
1852
|
+
target="_blank"
|
|
1853
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
1854
|
+
></a>
|
|
1855
|
+
<span class="property-type">string</span>
|
|
1856
|
+
</dt>
|
|
1857
|
+
<dd>Filter messages by the run ID that generated them.</dd>
|
|
1858
|
+
|
|
1834
1859
|
</dl>
|
|
1835
1860
|
|
|
1836
1861
|
<h3>Create Message</h3>
|
|
@@ -2224,6 +2249,90 @@
|
|
|
2224
2249
|
<span class="property-type">object</span>
|
|
2225
2250
|
</dt>
|
|
2226
2251
|
<dd>Set of 16 key-value pairs that can be attached to an object.</dd>
|
|
2252
|
+
|
|
2253
|
+
|
|
2254
|
+
<dt class="optional">
|
|
2255
|
+
temperature
|
|
2256
|
+
<a
|
|
2257
|
+
href="https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-temperature"
|
|
2258
|
+
target="_blank"
|
|
2259
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2260
|
+
></a>
|
|
2261
|
+
<span class="property-type">number</span>
|
|
2262
|
+
</dt>
|
|
2263
|
+
<dd>What sampling temperature to use, between 0 and 2.</dd>
|
|
2264
|
+
|
|
2265
|
+
<dt class="optional">
|
|
2266
|
+
stream
|
|
2267
|
+
<a
|
|
2268
|
+
href="https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-stream"
|
|
2269
|
+
target="_blank"
|
|
2270
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2271
|
+
></a>
|
|
2272
|
+
<span class="property-type">boolean</span>
|
|
2273
|
+
</dt>
|
|
2274
|
+
<dd>If <code>true</code>, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a <code>data: [DONE]</code> message.</dd>
|
|
2275
|
+
|
|
2276
|
+
<dt class="optional">
|
|
2277
|
+
max_prompt_tokens
|
|
2278
|
+
<a
|
|
2279
|
+
href="https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-max_prompt_tokens"
|
|
2280
|
+
target="_blank"
|
|
2281
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2282
|
+
></a>
|
|
2283
|
+
<span class="property-type">integer</span>
|
|
2284
|
+
</dt>
|
|
2285
|
+
<dd>The maximum number of prompt tokens that may be used over the course of the run.</dd>
|
|
2286
|
+
|
|
2287
|
+
<dt class="optional">
|
|
2288
|
+
max_completion_tokens
|
|
2289
|
+
<a
|
|
2290
|
+
href="https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-max_completion_tokens"
|
|
2291
|
+
target="_blank"
|
|
2292
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2293
|
+
></a>
|
|
2294
|
+
<span class="property-type">integer</span>
|
|
2295
|
+
</dt>
|
|
2296
|
+
<dd>The maximum number of completion tokens that may be used over the course of the run.</dd>
|
|
2297
|
+
|
|
2298
|
+
<dt class="optional">
|
|
2299
|
+
truncation_strategy
|
|
2300
|
+
<a
|
|
2301
|
+
href="https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-truncation_strategy"
|
|
2302
|
+
target="_blank"
|
|
2303
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2304
|
+
></a>
|
|
2305
|
+
<span class="property-type">object</span>
|
|
2306
|
+
<dd>
|
|
2307
|
+
<strong><code>@property {string} type</code></strong> - The truncation strategy to use for the thread. The default is <code>auto</code>. If set to <code>last_messages</code>, the thread will be truncated to the n most recent messages in the thread. When set to <code>auto</code>, messages in the middle of the thread will be dropped to fit the context length of the model, <code>max_prompt_tokens</code>.
|
|
2308
|
+
</dd>
|
|
2309
|
+
<dd>
|
|
2310
|
+
<strong><code>@property {integer} [last_messages]</code></strong> - The number of most recent messages from the thread when constructing the context for the run.
|
|
2311
|
+
</dd>
|
|
2312
|
+
</dt>
|
|
2313
|
+
|
|
2314
|
+
<dt class="optional">
|
|
2315
|
+
tool_choice
|
|
2316
|
+
<a
|
|
2317
|
+
href="https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-tool_choice"
|
|
2318
|
+
target="_blank"
|
|
2319
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2320
|
+
></a>
|
|
2321
|
+
<span class="property-type">string | object</span>
|
|
2322
|
+
</dt>
|
|
2323
|
+
<dd>Controls which (if any) tool is called by the model. <code>none</code> means the model will not call any tools and instead generates a message. <code>auto</code> is the default value and means the model can pick between generating a message or calling a tool. Specifying a particular tool like <code>{"type": "TOOL_TYPE"}</code> forces the model to call that tool.</dd>
|
|
2324
|
+
|
|
2325
|
+
<dt class="optional">
|
|
2326
|
+
response_format
|
|
2327
|
+
<a
|
|
2328
|
+
href="https://platform.openai.com/docs/api-reference/runs/createThreadAndRun#runs-createthreadandrun-response_format"
|
|
2329
|
+
target="_blank"
|
|
2330
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2331
|
+
></a>
|
|
2332
|
+
<span class="property-type">string | object</span>
|
|
2333
|
+
</dt>
|
|
2334
|
+
<dd>Specifies the format that the model must output.</dd>
|
|
2335
|
+
|
|
2227
2336
|
</dl>
|
|
2228
2337
|
|
|
2229
2338
|
<h2>List Runs</h2>
|
|
@@ -2328,9 +2437,35 @@
|
|
|
2328
2437
|
<span class="property-type">string</span>
|
|
2329
2438
|
</dt>
|
|
2330
2439
|
<dd>
|
|
2331
|
-
|
|
2332
|
-
run.
|
|
2440
|
+
Overrides the instructions of the assistant. This is useful for modifying the behavior on a per-run basis.
|
|
2333
2441
|
</dd>
|
|
2442
|
+
|
|
2443
|
+
<dt class="optional">
|
|
2444
|
+
additional_instructions
|
|
2445
|
+
<a
|
|
2446
|
+
href="https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-additional_instructions"
|
|
2447
|
+
target="_blank"
|
|
2448
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2449
|
+
></a>
|
|
2450
|
+
<span class="property-type">string</span>
|
|
2451
|
+
</dt>
|
|
2452
|
+
<dd>
|
|
2453
|
+
Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions.
|
|
2454
|
+
</dd>
|
|
2455
|
+
|
|
2456
|
+
<dt class="optional">
|
|
2457
|
+
additional_messages
|
|
2458
|
+
<a
|
|
2459
|
+
href="https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-additional_messages"
|
|
2460
|
+
target="_blank"
|
|
2461
|
+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
|
|
2462
|
+
></a>
|
|
2463
|
+
<span class="property-type">array</span>
|
|
2464
|
+
</dt>
|
|
2465
|
+
<dd>
|
|
2466
|
+
Adds additional messages to the thread before creating the run.
|
|
2467
|
+
</dd>
|
|
2468
|
+
|
|
2334
2469
|
<dt class="optional">
|
|
2335
2470
|
tools
|
|
2336
2471
|
<a
|
|
@@ -2789,4 +2924,4 @@
|
|
|
2789
2924
|
<script type="text/html" data-help-name="Service Host">
|
|
2790
2925
|
<p><b>Header</b>: Variable name to set API key</p>
|
|
2791
2926
|
<p><b>Value</b>: Value of API key</p>
|
|
2792
|
-
</script>
|
|
2927
|
+
</script>
|
package/node.js
CHANGED
|
@@ -11,7 +11,15 @@ module.exports = function (RED) {
|
|
|
11
11
|
node.config = config;
|
|
12
12
|
|
|
13
13
|
node.on("input", function (msg) {
|
|
14
|
-
let
|
|
14
|
+
let clientApiKey = node.service.credentials.secureApiKeyValue || "";
|
|
15
|
+
let clientApiBase = node.service.apiBase;
|
|
16
|
+
let clientOrganization = node.service.organizationId;
|
|
17
|
+
|
|
18
|
+
let client = new lib.OpenaiApi(
|
|
19
|
+
clientApiKey,
|
|
20
|
+
clientApiBase,
|
|
21
|
+
clientOrganization,
|
|
22
|
+
);
|
|
15
23
|
let payload;
|
|
16
24
|
|
|
17
25
|
const propertyType = node.config.propertyType || "msg";
|
|
@@ -26,9 +34,6 @@ module.exports = function (RED) {
|
|
|
26
34
|
|
|
27
35
|
const serviceName = node.config.method; // Set the service name to call.
|
|
28
36
|
let serviceParametersObject = {
|
|
29
|
-
organization: node.service.organizationId,
|
|
30
|
-
apiBase: node.service.apiBase,
|
|
31
|
-
apiKey: node.service.credentials.secureApiKeyValue || "",
|
|
32
37
|
_node: node,
|
|
33
38
|
msg: msg,
|
|
34
39
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inductiv/node-red-openai-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"ai"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"openai": "^4.
|
|
30
|
+
"openai": "^4.36.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"eslint": "^8.54.0",
|