@inductiv/node-red-openai-api 0.4.0 → 0.4.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.
- package/lib.js +202 -100
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -9,11 +9,13 @@ let OpenaiApi = (function () {
|
|
|
9
9
|
let node = parameters._node;
|
|
10
10
|
delete parameters._node;
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const clientParams = {
|
|
13
13
|
apiKey: parameters.apiKey,
|
|
14
14
|
baseURL: parameters.apiBase,
|
|
15
15
|
organization: parameters.organization,
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const openai = new OpenAI(clientParams);
|
|
17
19
|
const response = await openai.chat.completions.create({
|
|
18
20
|
...parameters.payload,
|
|
19
21
|
});
|
|
@@ -29,10 +31,14 @@ let OpenaiApi = (function () {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
async createImage(parameters) {
|
|
32
|
-
|
|
34
|
+
|
|
35
|
+
const clientParams = {
|
|
33
36
|
apiKey: parameters.apiKey,
|
|
37
|
+
baseURL: parameters.apiBase,
|
|
34
38
|
organization: parameters.organization,
|
|
35
|
-
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const openai = new OpenAI(clientParams);
|
|
36
42
|
const response = await openai.images.generate({
|
|
37
43
|
...parameters.payload,
|
|
38
44
|
});
|
|
@@ -41,10 +47,12 @@ let OpenaiApi = (function () {
|
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
async createImageEdit(parameters) {
|
|
44
|
-
const
|
|
50
|
+
const clientParams = {
|
|
45
51
|
apiKey: parameters.apiKey,
|
|
52
|
+
baseURL: parameters.apiBase,
|
|
46
53
|
organization: parameters.organization,
|
|
47
|
-
}
|
|
54
|
+
}
|
|
55
|
+
const openai = new OpenAI(clientParams);
|
|
48
56
|
|
|
49
57
|
parameters.payload.image = fs.createReadStream(parameters.payload.image);
|
|
50
58
|
if (parameters.payload.mask) {
|
|
@@ -59,10 +67,12 @@ let OpenaiApi = (function () {
|
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
async createImageVariation(parameters) {
|
|
62
|
-
const
|
|
70
|
+
const clientParams = {
|
|
63
71
|
apiKey: parameters.apiKey,
|
|
72
|
+
baseURL: parameters.apiBase,
|
|
64
73
|
organization: parameters.organization,
|
|
65
|
-
}
|
|
74
|
+
}
|
|
75
|
+
const openai = new OpenAI(clientParams);
|
|
66
76
|
|
|
67
77
|
parameters.payload.image = fs.createReadStream(parameters.payload.image);
|
|
68
78
|
const response = await openai.images.createVariation({
|
|
@@ -73,10 +83,12 @@ let OpenaiApi = (function () {
|
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
async createEmbedding(parameters) {
|
|
76
|
-
const
|
|
86
|
+
const clientParams = {
|
|
77
87
|
apiKey: parameters.apiKey,
|
|
88
|
+
baseURL: parameters.apiBase,
|
|
78
89
|
organization: parameters.organization,
|
|
79
|
-
}
|
|
90
|
+
}
|
|
91
|
+
const openai = new OpenAI(clientParams);
|
|
80
92
|
|
|
81
93
|
const response = await openai.embeddings.create({
|
|
82
94
|
...parameters.payload,
|
|
@@ -86,10 +98,12 @@ let OpenaiApi = (function () {
|
|
|
86
98
|
}
|
|
87
99
|
|
|
88
100
|
async createSpeech(parameters) {
|
|
89
|
-
const
|
|
101
|
+
const clientParams = {
|
|
90
102
|
apiKey: parameters.apiKey,
|
|
103
|
+
baseURL: parameters.apiBase,
|
|
91
104
|
organization: parameters.organization,
|
|
92
|
-
}
|
|
105
|
+
}
|
|
106
|
+
const openai = new OpenAI(clientParams);
|
|
93
107
|
|
|
94
108
|
const audio = await openai.audio.speech.create({ ...parameters.payload });
|
|
95
109
|
const response = Buffer.from(await audio.arrayBuffer());
|
|
@@ -98,10 +112,12 @@ let OpenaiApi = (function () {
|
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
async createTranscription(parameters) {
|
|
101
|
-
const
|
|
115
|
+
const clientParams = {
|
|
102
116
|
apiKey: parameters.apiKey,
|
|
117
|
+
baseURL: parameters.apiBase,
|
|
103
118
|
organization: parameters.organization,
|
|
104
|
-
}
|
|
119
|
+
}
|
|
120
|
+
const openai = new OpenAI(clientParams);
|
|
105
121
|
|
|
106
122
|
parameters.payload.file = fs.createReadStream(parameters.payload.file);
|
|
107
123
|
|
|
@@ -113,10 +129,12 @@ let OpenaiApi = (function () {
|
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
async createTranslation(parameters) {
|
|
116
|
-
const
|
|
132
|
+
const clientParams = {
|
|
117
133
|
apiKey: parameters.apiKey,
|
|
134
|
+
baseURL: parameters.apiBase,
|
|
118
135
|
organization: parameters.organization,
|
|
119
|
-
}
|
|
136
|
+
}
|
|
137
|
+
const openai = new OpenAI(clientParams);
|
|
120
138
|
|
|
121
139
|
parameters.payload.file = fs.createReadStream(parameters.payload.file);
|
|
122
140
|
const response = await openai.audio.translations.create({
|
|
@@ -127,10 +145,12 @@ let OpenaiApi = (function () {
|
|
|
127
145
|
}
|
|
128
146
|
|
|
129
147
|
async listFiles(parameters) {
|
|
130
|
-
const
|
|
148
|
+
const clientParams = {
|
|
131
149
|
apiKey: parameters.apiKey,
|
|
150
|
+
baseURL: parameters.apiBase,
|
|
132
151
|
organization: parameters.organization,
|
|
133
|
-
}
|
|
152
|
+
}
|
|
153
|
+
const openai = new OpenAI(clientParams);
|
|
134
154
|
|
|
135
155
|
const list = await openai.files.list({
|
|
136
156
|
...parameters.payload,
|
|
@@ -145,10 +165,12 @@ let OpenaiApi = (function () {
|
|
|
145
165
|
}
|
|
146
166
|
|
|
147
167
|
async createFile(parameters) {
|
|
148
|
-
const
|
|
168
|
+
const clientParams = {
|
|
149
169
|
apiKey: parameters.apiKey,
|
|
170
|
+
baseURL: parameters.apiBase,
|
|
150
171
|
organization: parameters.organization,
|
|
151
|
-
}
|
|
172
|
+
}
|
|
173
|
+
const openai = new OpenAI(clientParams);
|
|
152
174
|
|
|
153
175
|
parameters.payload.file = fs.createReadStream(parameters.payload.file);
|
|
154
176
|
const response = await openai.files.create({
|
|
@@ -158,10 +180,12 @@ let OpenaiApi = (function () {
|
|
|
158
180
|
return response;
|
|
159
181
|
}
|
|
160
182
|
async deleteFile(parameters) {
|
|
161
|
-
const
|
|
183
|
+
const clientParams = {
|
|
162
184
|
apiKey: parameters.apiKey,
|
|
185
|
+
baseURL: parameters.apiBase,
|
|
163
186
|
organization: parameters.organization,
|
|
164
|
-
}
|
|
187
|
+
}
|
|
188
|
+
const openai = new OpenAI(clientParams);
|
|
165
189
|
|
|
166
190
|
const response = await openai.files.del({
|
|
167
191
|
...parameters.payload,
|
|
@@ -170,10 +194,12 @@ let OpenaiApi = (function () {
|
|
|
170
194
|
return response;
|
|
171
195
|
}
|
|
172
196
|
async retrieveFile(parameters) {
|
|
173
|
-
const
|
|
197
|
+
const clientParams = {
|
|
174
198
|
apiKey: parameters.apiKey,
|
|
199
|
+
baseURL: parameters.apiBase,
|
|
175
200
|
organization: parameters.organization,
|
|
176
|
-
}
|
|
201
|
+
}
|
|
202
|
+
const openai = new OpenAI(clientParams);
|
|
177
203
|
|
|
178
204
|
const file_id = parameters.payload.file_id;
|
|
179
205
|
delete parameters.payload.file_id;
|
|
@@ -185,10 +211,12 @@ let OpenaiApi = (function () {
|
|
|
185
211
|
return response;
|
|
186
212
|
}
|
|
187
213
|
async downloadFile(parameters) {
|
|
188
|
-
const
|
|
214
|
+
const clientParams = {
|
|
189
215
|
apiKey: parameters.apiKey,
|
|
216
|
+
baseURL: parameters.apiBase,
|
|
190
217
|
organization: parameters.organization,
|
|
191
|
-
}
|
|
218
|
+
}
|
|
219
|
+
const openai = new OpenAI(clientParams);
|
|
192
220
|
|
|
193
221
|
const file_id = parameters.payload.file_id;
|
|
194
222
|
delete parameters.payload.file_id;
|
|
@@ -200,10 +228,12 @@ let OpenaiApi = (function () {
|
|
|
200
228
|
return response;
|
|
201
229
|
}
|
|
202
230
|
async createFineTuningJob(parameters) {
|
|
203
|
-
const
|
|
231
|
+
const clientParams = {
|
|
204
232
|
apiKey: parameters.apiKey,
|
|
233
|
+
baseURL: parameters.apiBase,
|
|
205
234
|
organization: parameters.organization,
|
|
206
|
-
}
|
|
235
|
+
}
|
|
236
|
+
const openai = new OpenAI(clientParams);
|
|
207
237
|
|
|
208
238
|
const response = await openai.fineTuning.jobs.create({
|
|
209
239
|
...parameters.payload,
|
|
@@ -212,10 +242,12 @@ let OpenaiApi = (function () {
|
|
|
212
242
|
return response;
|
|
213
243
|
}
|
|
214
244
|
async listPaginatedFineTuningJobs(parameters) {
|
|
215
|
-
const
|
|
245
|
+
const clientParams = {
|
|
216
246
|
apiKey: parameters.apiKey,
|
|
247
|
+
baseURL: parameters.apiBase,
|
|
217
248
|
organization: parameters.organization,
|
|
218
|
-
}
|
|
249
|
+
}
|
|
250
|
+
const openai = new OpenAI(clientParams);
|
|
219
251
|
|
|
220
252
|
const list = await openai.fineTuning.jobs.list({
|
|
221
253
|
...parameters.payload,
|
|
@@ -229,10 +261,12 @@ let OpenaiApi = (function () {
|
|
|
229
261
|
return response;
|
|
230
262
|
}
|
|
231
263
|
async retrieveFineTuningJob(parameters) {
|
|
232
|
-
const
|
|
264
|
+
const clientParams = {
|
|
233
265
|
apiKey: parameters.apiKey,
|
|
266
|
+
baseURL: parameters.apiBase,
|
|
234
267
|
organization: parameters.organization,
|
|
235
|
-
}
|
|
268
|
+
}
|
|
269
|
+
const openai = new OpenAI(clientParams);
|
|
236
270
|
|
|
237
271
|
const response = await openai.fineTuning.jobs.retrieve(
|
|
238
272
|
parameters.payload.fine_tuning_job_id,
|
|
@@ -241,10 +275,12 @@ let OpenaiApi = (function () {
|
|
|
241
275
|
return response;
|
|
242
276
|
}
|
|
243
277
|
async listFineTuningEvents(parameters) {
|
|
244
|
-
const
|
|
278
|
+
const clientParams = {
|
|
245
279
|
apiKey: parameters.apiKey,
|
|
280
|
+
baseURL: parameters.apiBase,
|
|
246
281
|
organization: parameters.organization,
|
|
247
|
-
}
|
|
282
|
+
}
|
|
283
|
+
const openai = new OpenAI(clientParams);
|
|
248
284
|
|
|
249
285
|
let response = [];
|
|
250
286
|
const list = await openai.fineTuning.jobs.listEvents(
|
|
@@ -256,10 +292,12 @@ let OpenaiApi = (function () {
|
|
|
256
292
|
return response;
|
|
257
293
|
}
|
|
258
294
|
async cancelFineTuningJob(parameters) {
|
|
259
|
-
const
|
|
295
|
+
const clientParams = {
|
|
260
296
|
apiKey: parameters.apiKey,
|
|
297
|
+
baseURL: parameters.apiBase,
|
|
261
298
|
organization: parameters.organization,
|
|
262
|
-
}
|
|
299
|
+
}
|
|
300
|
+
const openai = new OpenAI(clientParams);
|
|
263
301
|
|
|
264
302
|
const response = await openai.fineTuning.jobs.cancel(
|
|
265
303
|
parameters.payload.fine_tuning_job_id,
|
|
@@ -268,20 +306,24 @@ let OpenaiApi = (function () {
|
|
|
268
306
|
return response;
|
|
269
307
|
}
|
|
270
308
|
async listModels(parameters) {
|
|
271
|
-
const
|
|
309
|
+
const clientParams = {
|
|
272
310
|
apiKey: parameters.apiKey,
|
|
311
|
+
baseURL: parameters.apiBase,
|
|
273
312
|
organization: parameters.organization,
|
|
274
|
-
}
|
|
313
|
+
}
|
|
314
|
+
const openai = new OpenAI(clientParams);
|
|
275
315
|
|
|
276
316
|
const response = await openai.models.list();
|
|
277
317
|
|
|
278
318
|
return response.body;
|
|
279
319
|
}
|
|
280
320
|
async retrieveModel(parameters) {
|
|
281
|
-
const
|
|
321
|
+
const clientParams = {
|
|
282
322
|
apiKey: parameters.apiKey,
|
|
323
|
+
baseURL: parameters.apiBase,
|
|
283
324
|
organization: parameters.organization,
|
|
284
|
-
}
|
|
325
|
+
}
|
|
326
|
+
const openai = new OpenAI(clientParams);
|
|
285
327
|
|
|
286
328
|
const model = parameters.payload.model;
|
|
287
329
|
const response = await openai.models.retrieve(model);
|
|
@@ -289,10 +331,12 @@ let OpenaiApi = (function () {
|
|
|
289
331
|
return response;
|
|
290
332
|
}
|
|
291
333
|
async deleteModel(parameters) {
|
|
292
|
-
const
|
|
334
|
+
const clientParams = {
|
|
293
335
|
apiKey: parameters.apiKey,
|
|
336
|
+
baseURL: parameters.apiBase,
|
|
294
337
|
organization: parameters.organization,
|
|
295
|
-
}
|
|
338
|
+
}
|
|
339
|
+
const openai = new OpenAI(clientParams);
|
|
296
340
|
|
|
297
341
|
const model = parameters.payload.model;
|
|
298
342
|
const response = await openai.models.del(model);
|
|
@@ -300,19 +344,23 @@ let OpenaiApi = (function () {
|
|
|
300
344
|
return response;
|
|
301
345
|
}
|
|
302
346
|
async createModeration(parameters) {
|
|
303
|
-
const
|
|
347
|
+
const clientParams = {
|
|
304
348
|
apiKey: parameters.apiKey,
|
|
349
|
+
baseURL: parameters.apiBase,
|
|
305
350
|
organization: parameters.organization,
|
|
306
|
-
}
|
|
351
|
+
}
|
|
352
|
+
const openai = new OpenAI(clientParams);
|
|
307
353
|
|
|
308
354
|
const response = await openai.moderations.create(parameters.payload);
|
|
309
355
|
return response;
|
|
310
356
|
}
|
|
311
357
|
async listAssistants(parameters) {
|
|
312
|
-
const
|
|
358
|
+
const clientParams = {
|
|
313
359
|
apiKey: parameters.apiKey,
|
|
360
|
+
baseURL: parameters.apiBase,
|
|
314
361
|
organization: parameters.organization,
|
|
315
|
-
}
|
|
362
|
+
}
|
|
363
|
+
const openai = new OpenAI(clientParams);
|
|
316
364
|
|
|
317
365
|
const response = await openai.beta.assistants.list({
|
|
318
366
|
...parameters.payload,
|
|
@@ -321,10 +369,12 @@ let OpenaiApi = (function () {
|
|
|
321
369
|
return response.body;
|
|
322
370
|
}
|
|
323
371
|
async createAssistant(parameters) {
|
|
324
|
-
const
|
|
372
|
+
const clientParams = {
|
|
325
373
|
apiKey: parameters.apiKey,
|
|
374
|
+
baseURL: parameters.apiBase,
|
|
326
375
|
organization: parameters.organization,
|
|
327
|
-
}
|
|
376
|
+
}
|
|
377
|
+
const openai = new OpenAI(clientParams);
|
|
328
378
|
|
|
329
379
|
const response = await openai.beta.assistants.create({
|
|
330
380
|
...parameters.payload,
|
|
@@ -333,10 +383,12 @@ let OpenaiApi = (function () {
|
|
|
333
383
|
return response;
|
|
334
384
|
}
|
|
335
385
|
async getAssistant(parameters) {
|
|
336
|
-
const
|
|
386
|
+
const clientParams = {
|
|
337
387
|
apiKey: parameters.apiKey,
|
|
388
|
+
baseURL: parameters.apiBase,
|
|
338
389
|
organization: parameters.organization,
|
|
339
|
-
}
|
|
390
|
+
}
|
|
391
|
+
const openai = new OpenAI(clientParams);
|
|
340
392
|
|
|
341
393
|
const id = parameters.payload.assistant_id;
|
|
342
394
|
const response = await openai.beta.assistants.retrieve(id);
|
|
@@ -344,10 +396,12 @@ let OpenaiApi = (function () {
|
|
|
344
396
|
return response;
|
|
345
397
|
}
|
|
346
398
|
async modifyAssistant(parameters) {
|
|
347
|
-
const
|
|
399
|
+
const clientParams = {
|
|
348
400
|
apiKey: parameters.apiKey,
|
|
401
|
+
baseURL: parameters.apiBase,
|
|
349
402
|
organization: parameters.organization,
|
|
350
|
-
}
|
|
403
|
+
}
|
|
404
|
+
const openai = new OpenAI(clientParams);
|
|
351
405
|
|
|
352
406
|
const id = parameters.payload.assistant_id;
|
|
353
407
|
delete parameters.payload.assistant_id;
|
|
@@ -359,10 +413,12 @@ let OpenaiApi = (function () {
|
|
|
359
413
|
return response;
|
|
360
414
|
}
|
|
361
415
|
async deleteAssistant(parameters) {
|
|
362
|
-
const
|
|
416
|
+
const clientParams = {
|
|
363
417
|
apiKey: parameters.apiKey,
|
|
418
|
+
baseURL: parameters.apiBase,
|
|
364
419
|
organization: parameters.organization,
|
|
365
|
-
}
|
|
420
|
+
}
|
|
421
|
+
const openai = new OpenAI(clientParams);
|
|
366
422
|
|
|
367
423
|
const id = parameters.payload.assistant_id;
|
|
368
424
|
const response = await openai.beta.assistants.del(id);
|
|
@@ -370,10 +426,12 @@ let OpenaiApi = (function () {
|
|
|
370
426
|
return response;
|
|
371
427
|
}
|
|
372
428
|
async createThread(parameters) {
|
|
373
|
-
const
|
|
429
|
+
const clientParams = {
|
|
374
430
|
apiKey: parameters.apiKey,
|
|
431
|
+
baseURL: parameters.apiBase,
|
|
375
432
|
organization: parameters.organization,
|
|
376
|
-
}
|
|
433
|
+
}
|
|
434
|
+
const openai = new OpenAI(clientParams);
|
|
377
435
|
|
|
378
436
|
const response = await openai.beta.threads.create({
|
|
379
437
|
...parameters.payload,
|
|
@@ -382,10 +440,12 @@ let OpenaiApi = (function () {
|
|
|
382
440
|
return response;
|
|
383
441
|
}
|
|
384
442
|
async getThread(parameters) {
|
|
385
|
-
const
|
|
443
|
+
const clientParams = {
|
|
386
444
|
apiKey: parameters.apiKey,
|
|
445
|
+
baseURL: parameters.apiBase,
|
|
387
446
|
organization: parameters.organization,
|
|
388
|
-
}
|
|
447
|
+
}
|
|
448
|
+
const openai = new OpenAI(clientParams);
|
|
389
449
|
|
|
390
450
|
const id = parameters.payload.thread_id;
|
|
391
451
|
const response = await openai.beta.threads.retrieve(id);
|
|
@@ -393,10 +453,12 @@ let OpenaiApi = (function () {
|
|
|
393
453
|
return response;
|
|
394
454
|
}
|
|
395
455
|
async modifyThread(parameters) {
|
|
396
|
-
const
|
|
456
|
+
const clientParams = {
|
|
397
457
|
apiKey: parameters.apiKey,
|
|
458
|
+
baseURL: parameters.apiBase,
|
|
398
459
|
organization: parameters.organization,
|
|
399
|
-
}
|
|
460
|
+
}
|
|
461
|
+
const openai = new OpenAI(clientParams);
|
|
400
462
|
|
|
401
463
|
const id = parameters.payload.thread_id;
|
|
402
464
|
delete parameters.payload.thread_id;
|
|
@@ -408,10 +470,12 @@ let OpenaiApi = (function () {
|
|
|
408
470
|
return response;
|
|
409
471
|
}
|
|
410
472
|
async deleteThread(parameters) {
|
|
411
|
-
const
|
|
473
|
+
const clientParams = {
|
|
412
474
|
apiKey: parameters.apiKey,
|
|
475
|
+
baseURL: parameters.apiBase,
|
|
413
476
|
organization: parameters.organization,
|
|
414
|
-
}
|
|
477
|
+
}
|
|
478
|
+
const openai = new OpenAI(clientParams);
|
|
415
479
|
|
|
416
480
|
const id = parameters.payload.thread_id;
|
|
417
481
|
const response = await openai.beta.threads.del(id);
|
|
@@ -419,10 +483,12 @@ let OpenaiApi = (function () {
|
|
|
419
483
|
return response;
|
|
420
484
|
}
|
|
421
485
|
async listMessages(parameters) {
|
|
422
|
-
const
|
|
486
|
+
const clientParams = {
|
|
423
487
|
apiKey: parameters.apiKey,
|
|
488
|
+
baseURL: parameters.apiBase,
|
|
424
489
|
organization: parameters.organization,
|
|
425
|
-
}
|
|
490
|
+
}
|
|
491
|
+
const openai = new OpenAI(clientParams);
|
|
426
492
|
|
|
427
493
|
const id = parameters.payload.thread_id;
|
|
428
494
|
const response = await openai.beta.threads.messages.list(id);
|
|
@@ -430,10 +496,12 @@ let OpenaiApi = (function () {
|
|
|
430
496
|
return response.body;
|
|
431
497
|
}
|
|
432
498
|
async createMessage(parameters) {
|
|
433
|
-
const
|
|
499
|
+
const clientParams = {
|
|
434
500
|
apiKey: parameters.apiKey,
|
|
501
|
+
baseURL: parameters.apiBase,
|
|
435
502
|
organization: parameters.organization,
|
|
436
|
-
}
|
|
503
|
+
}
|
|
504
|
+
const openai = new OpenAI(clientParams);
|
|
437
505
|
|
|
438
506
|
const thread_id = parameters.payload.thread_id;
|
|
439
507
|
delete parameters.payload.thread_id;
|
|
@@ -445,10 +513,12 @@ let OpenaiApi = (function () {
|
|
|
445
513
|
return response;
|
|
446
514
|
}
|
|
447
515
|
async getMessage(parameters) {
|
|
448
|
-
const
|
|
516
|
+
const clientParams = {
|
|
449
517
|
apiKey: parameters.apiKey,
|
|
518
|
+
baseURL: parameters.apiBase,
|
|
450
519
|
organization: parameters.organization,
|
|
451
|
-
}
|
|
520
|
+
}
|
|
521
|
+
const openai = new OpenAI(clientParams);
|
|
452
522
|
|
|
453
523
|
const thread_id = parameters.payload.thread_id;
|
|
454
524
|
const message_id = parameters.payload.message_id;
|
|
@@ -461,10 +531,12 @@ let OpenaiApi = (function () {
|
|
|
461
531
|
return response;
|
|
462
532
|
}
|
|
463
533
|
async modifyMessage(parameters) {
|
|
464
|
-
const
|
|
534
|
+
const clientParams = {
|
|
465
535
|
apiKey: parameters.apiKey,
|
|
536
|
+
baseURL: parameters.apiBase,
|
|
466
537
|
organization: parameters.organization,
|
|
467
|
-
}
|
|
538
|
+
}
|
|
539
|
+
const openai = new OpenAI(clientParams);
|
|
468
540
|
|
|
469
541
|
const thread_id = parameters.payload.thread_id;
|
|
470
542
|
const message_id = parameters.payload.message_id;
|
|
@@ -482,10 +554,12 @@ let OpenaiApi = (function () {
|
|
|
482
554
|
return response;
|
|
483
555
|
}
|
|
484
556
|
async createThreadAndRun(parameters) {
|
|
485
|
-
const
|
|
557
|
+
const clientParams = {
|
|
486
558
|
apiKey: parameters.apiKey,
|
|
559
|
+
baseURL: parameters.apiBase,
|
|
487
560
|
organization: parameters.organization,
|
|
488
|
-
}
|
|
561
|
+
}
|
|
562
|
+
const openai = new OpenAI(clientParams);
|
|
489
563
|
|
|
490
564
|
const response = await openai.beta.threads.createAndRun({
|
|
491
565
|
...parameters.payload,
|
|
@@ -494,10 +568,12 @@ let OpenaiApi = (function () {
|
|
|
494
568
|
return response;
|
|
495
569
|
}
|
|
496
570
|
async listRuns(parameters) {
|
|
497
|
-
const
|
|
571
|
+
const clientParams = {
|
|
498
572
|
apiKey: parameters.apiKey,
|
|
573
|
+
baseURL: parameters.apiBase,
|
|
499
574
|
organization: parameters.organization,
|
|
500
|
-
}
|
|
575
|
+
}
|
|
576
|
+
const openai = new OpenAI(clientParams);
|
|
501
577
|
|
|
502
578
|
const thred_id = parameters.payload.thread_id;
|
|
503
579
|
delete parameters.payload.thread_id;
|
|
@@ -509,10 +585,12 @@ let OpenaiApi = (function () {
|
|
|
509
585
|
return response.body;
|
|
510
586
|
}
|
|
511
587
|
async createRun(parameters) {
|
|
512
|
-
const
|
|
588
|
+
const clientParams = {
|
|
513
589
|
apiKey: parameters.apiKey,
|
|
590
|
+
baseURL: parameters.apiBase,
|
|
514
591
|
organization: parameters.organization,
|
|
515
|
-
}
|
|
592
|
+
}
|
|
593
|
+
const openai = new OpenAI(clientParams);
|
|
516
594
|
|
|
517
595
|
const thread_id = parameters.payload.thread_id;
|
|
518
596
|
delete parameters.payload.thread_id;
|
|
@@ -524,10 +602,12 @@ let OpenaiApi = (function () {
|
|
|
524
602
|
return response;
|
|
525
603
|
}
|
|
526
604
|
async getRun(parameters) {
|
|
527
|
-
const
|
|
605
|
+
const clientParams = {
|
|
528
606
|
apiKey: parameters.apiKey,
|
|
607
|
+
baseURL: parameters.apiBase,
|
|
529
608
|
organization: parameters.organization,
|
|
530
|
-
}
|
|
609
|
+
}
|
|
610
|
+
const openai = new OpenAI(clientParams);
|
|
531
611
|
|
|
532
612
|
const thread_id = parameters.payload.thread_id;
|
|
533
613
|
const run_id = parameters.payload.run_id;
|
|
@@ -542,10 +622,12 @@ let OpenaiApi = (function () {
|
|
|
542
622
|
return response;
|
|
543
623
|
}
|
|
544
624
|
async modifyRun(parameters) {
|
|
545
|
-
const
|
|
625
|
+
const clientParams = {
|
|
546
626
|
apiKey: parameters.apiKey,
|
|
627
|
+
baseURL: parameters.apiBase,
|
|
547
628
|
organization: parameters.organization,
|
|
548
|
-
}
|
|
629
|
+
}
|
|
630
|
+
const openai = new OpenAI(clientParams);
|
|
549
631
|
|
|
550
632
|
const thread_id = parameters.payload.thread_id;
|
|
551
633
|
const run_id = parameters.payload.run_id;
|
|
@@ -563,10 +645,12 @@ let OpenaiApi = (function () {
|
|
|
563
645
|
return response;
|
|
564
646
|
}
|
|
565
647
|
async submitToolOuputsToRun(parameters) {
|
|
566
|
-
const
|
|
648
|
+
const clientParams = {
|
|
567
649
|
apiKey: parameters.apiKey,
|
|
650
|
+
baseURL: parameters.apiBase,
|
|
568
651
|
organization: parameters.organization,
|
|
569
|
-
}
|
|
652
|
+
}
|
|
653
|
+
const openai = new OpenAI(clientParams);
|
|
570
654
|
|
|
571
655
|
const thread_id = parameters.payload.thread_id;
|
|
572
656
|
const run_id = parameters.payload.run_id;
|
|
@@ -584,10 +668,12 @@ let OpenaiApi = (function () {
|
|
|
584
668
|
return response;
|
|
585
669
|
}
|
|
586
670
|
async cancelRun(parameters) {
|
|
587
|
-
const
|
|
671
|
+
const clientParams = {
|
|
588
672
|
apiKey: parameters.apiKey,
|
|
673
|
+
baseURL: parameters.apiBase,
|
|
589
674
|
organization: parameters.organization,
|
|
590
|
-
}
|
|
675
|
+
}
|
|
676
|
+
const openai = new OpenAI(clientParams);
|
|
591
677
|
|
|
592
678
|
const thread_id = parameters.payload.thread_id;
|
|
593
679
|
const run_id = parameters.payload.run_id;
|
|
@@ -605,10 +691,12 @@ let OpenaiApi = (function () {
|
|
|
605
691
|
return response;
|
|
606
692
|
}
|
|
607
693
|
async listRunSteps(parameters) {
|
|
608
|
-
const
|
|
694
|
+
const clientParams = {
|
|
609
695
|
apiKey: parameters.apiKey,
|
|
696
|
+
baseURL: parameters.apiBase,
|
|
610
697
|
organization: parameters.organization,
|
|
611
|
-
}
|
|
698
|
+
}
|
|
699
|
+
const openai = new OpenAI(clientParams);
|
|
612
700
|
|
|
613
701
|
const thread_id = parameters.payload.thread_id;
|
|
614
702
|
const run_id = parameters.payload.run_id;
|
|
@@ -626,10 +714,12 @@ let OpenaiApi = (function () {
|
|
|
626
714
|
return response.body;
|
|
627
715
|
}
|
|
628
716
|
async getRunStep(parameters) {
|
|
629
|
-
const
|
|
717
|
+
const clientParams = {
|
|
630
718
|
apiKey: parameters.apiKey,
|
|
719
|
+
baseURL: parameters.apiBase,
|
|
631
720
|
organization: parameters.organization,
|
|
632
|
-
}
|
|
721
|
+
}
|
|
722
|
+
const openai = new OpenAI(clientParams);
|
|
633
723
|
|
|
634
724
|
const thread_id = parameters.payload.thread_id;
|
|
635
725
|
const run_id = parameters.payload.run_id;
|
|
@@ -644,10 +734,12 @@ let OpenaiApi = (function () {
|
|
|
644
734
|
return response;
|
|
645
735
|
}
|
|
646
736
|
async listAssistantFiles(parameters) {
|
|
647
|
-
const
|
|
737
|
+
const clientParams = {
|
|
648
738
|
apiKey: parameters.apiKey,
|
|
739
|
+
baseURL: parameters.apiBase,
|
|
649
740
|
organization: parameters.organization,
|
|
650
|
-
}
|
|
741
|
+
}
|
|
742
|
+
const openai = new OpenAI(clientParams);
|
|
651
743
|
|
|
652
744
|
const assistant_id = parameters.payload.assistant_id;
|
|
653
745
|
delete parameters.payload.assistant_id;
|
|
@@ -659,10 +751,12 @@ let OpenaiApi = (function () {
|
|
|
659
751
|
return response.body;
|
|
660
752
|
}
|
|
661
753
|
async createAssistantFile(parameters) {
|
|
662
|
-
const
|
|
754
|
+
const clientParams = {
|
|
663
755
|
apiKey: parameters.apiKey,
|
|
756
|
+
baseURL: parameters.apiBase,
|
|
664
757
|
organization: parameters.organization,
|
|
665
|
-
}
|
|
758
|
+
}
|
|
759
|
+
const openai = new OpenAI(clientParams);
|
|
666
760
|
|
|
667
761
|
const assistant_id = parameters.payload.assistant_id;
|
|
668
762
|
delete parameters.payload.assistant_id;
|
|
@@ -674,10 +768,12 @@ let OpenaiApi = (function () {
|
|
|
674
768
|
return response;
|
|
675
769
|
}
|
|
676
770
|
async getAssistantFile(parameters) {
|
|
677
|
-
const
|
|
771
|
+
const clientParams = {
|
|
678
772
|
apiKey: parameters.apiKey,
|
|
773
|
+
baseURL: parameters.apiBase,
|
|
679
774
|
organization: parameters.organization,
|
|
680
|
-
}
|
|
775
|
+
}
|
|
776
|
+
const openai = new OpenAI(clientParams);
|
|
681
777
|
|
|
682
778
|
const assistant_id = parameters.payload.assistant_id;
|
|
683
779
|
const file_id = parameters.payload.file_id;
|
|
@@ -695,10 +791,12 @@ let OpenaiApi = (function () {
|
|
|
695
791
|
return response;
|
|
696
792
|
}
|
|
697
793
|
async deleteAssistantFile(parameters) {
|
|
698
|
-
const
|
|
794
|
+
const clientParams = {
|
|
699
795
|
apiKey: parameters.apiKey,
|
|
796
|
+
baseURL: parameters.apiBase,
|
|
700
797
|
organization: parameters.organization,
|
|
701
|
-
}
|
|
798
|
+
}
|
|
799
|
+
const openai = new OpenAI(clientParams);
|
|
702
800
|
|
|
703
801
|
const assistant_id = parameters.payload.assistant_id;
|
|
704
802
|
const file_id = parameters.payload.file_id;
|
|
@@ -716,10 +814,12 @@ let OpenaiApi = (function () {
|
|
|
716
814
|
return response;
|
|
717
815
|
}
|
|
718
816
|
async listMessageFiles(parameters) {
|
|
719
|
-
const
|
|
817
|
+
const clientParams = {
|
|
720
818
|
apiKey: parameters.apiKey,
|
|
819
|
+
baseURL: parameters.apiBase,
|
|
721
820
|
organization: parameters.organization,
|
|
722
|
-
}
|
|
821
|
+
}
|
|
822
|
+
const openai = new OpenAI(clientParams);
|
|
723
823
|
|
|
724
824
|
const thread_id = parameters.payload.thread_id;
|
|
725
825
|
const message_id = parameters.payload.message_id;
|
|
@@ -737,10 +837,12 @@ let OpenaiApi = (function () {
|
|
|
737
837
|
return response;
|
|
738
838
|
}
|
|
739
839
|
async getMessageFile(parameters) {
|
|
740
|
-
const
|
|
840
|
+
const clientParams = {
|
|
741
841
|
apiKey: parameters.apiKey,
|
|
842
|
+
baseURL: parameters.apiBase,
|
|
742
843
|
organization: parameters.organization,
|
|
743
|
-
}
|
|
844
|
+
}
|
|
845
|
+
const openai = new OpenAI(clientParams);
|
|
744
846
|
|
|
745
847
|
const thread_id = parameters.payload.thread_id;
|
|
746
848
|
const message_id = parameters.payload.message_id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inductiv/node-red-openai-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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": {
|