@inductiv/node-red-openai-api 0.8.0 → 1.0.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.
@@ -1,16 +1,16 @@
1
1
  [
2
2
  {
3
- "id": "78b174792ca9efaf",
3
+ "id": "2e6fd52cd06882a1",
4
4
  "type": "tab",
5
- "label": "Assistants Examples",
5
+ "label": "Assistants V2 Examples",
6
6
  "disabled": false,
7
7
  "info": "",
8
8
  "env": []
9
9
  },
10
10
  {
11
- "id": "3aed22e8a8626b49",
11
+ "id": "b2325ede9b42d787",
12
12
  "type": "group",
13
- "z": "78b174792ca9efaf",
13
+ "z": "2e6fd52cd06882a1",
14
14
  "style": {
15
15
  "stroke": "#999999",
16
16
  "stroke-opacity": "1",
@@ -21,26 +21,26 @@
21
21
  "color": "#a4a4a4"
22
22
  },
23
23
  "nodes": [
24
- "a1dd9dd38256bc37",
25
- "94c58ec5fd3ce89a",
26
- "78bae2355d746f5b",
27
- "16fd166e2cfe1aec",
28
- "54cdefbcbbec117f",
29
- "e0007c022bce36b9",
30
- "e5b83cdfc84c22f9",
31
- "6ada9879e91ef156",
32
- "a08cc5475a20cc70"
24
+ "4a8b69a0d666e4b1",
25
+ "c93a90f1145d7097",
26
+ "80f2fcaea376e6fa",
27
+ "7d03d073350147e7",
28
+ "6e0b6eedb964bb59",
29
+ "f478ebac3078686d",
30
+ "979ed3ff6205acfb",
31
+ "5b0b2790637ab2b5",
32
+ "b0c1fc6cafdb4e10"
33
33
  ],
34
34
  "x": 94,
35
35
  "y": 113,
36
- "w": 1472,
37
- "h": 374
36
+ "w": 1732,
37
+ "h": 308
38
38
  },
39
39
  {
40
- "id": "6ada9879e91ef156",
40
+ "id": "f478ebac3078686d",
41
41
  "type": "group",
42
- "z": "78b174792ca9efaf",
43
- "g": "3aed22e8a8626b49",
42
+ "z": "2e6fd52cd06882a1",
43
+ "g": "b2325ede9b42d787",
44
44
  "style": {
45
45
  "stroke": "#999999",
46
46
  "stroke-opacity": "1",
@@ -51,45 +51,23 @@
51
51
  "color": "#a4a4a4"
52
52
  },
53
53
  "nodes": [
54
- "7a825447030eb842",
55
- "e78656f2a1db4141",
56
- "a342bcf840361d49",
57
- "da5c242d75d45b1a",
58
- "faf6244b17ba1131"
54
+ "fa3a845583809a96",
55
+ "b7515492cea3f1fb",
56
+ "dc3d68ba96e95f34",
57
+ "47e765406b4b7af7",
58
+ "4bfcbf55e88e61dd",
59
+ "ab3a2c80ba3eacbd"
59
60
  ],
60
- "x": 454,
61
+ "x": 334,
61
62
  "y": 139,
62
- "w": 832,
63
+ "w": 1112,
63
64
  "h": 122
64
65
  },
65
66
  {
66
- "id": "a08cc5475a20cc70",
67
- "type": "group",
68
- "z": "78b174792ca9efaf",
69
- "g": "3aed22e8a8626b49",
70
- "style": {
71
- "stroke": "#999999",
72
- "stroke-opacity": "1",
73
- "fill": "none",
74
- "fill-opacity": "1",
75
- "label": true,
76
- "label-position": "nw",
77
- "color": "#a4a4a4"
78
- },
79
- "nodes": [
80
- "d0ed57739e76eba4",
81
- "a319c0690ad183bc"
82
- ],
83
- "x": 454,
84
- "y": 339,
85
- "w": 212,
86
- "h": 122
87
- },
88
- {
89
- "id": "a1dd9dd38256bc37",
67
+ "id": "4a8b69a0d666e4b1",
90
68
  "type": "debug",
91
- "z": "78b174792ca9efaf",
92
- "g": "3aed22e8a8626b49",
69
+ "z": "2e6fd52cd06882a1",
70
+ "g": "b2325ede9b42d787",
93
71
  "name": "response",
94
72
  "active": true,
95
73
  "tosidebar": true,
@@ -99,37 +77,33 @@
99
77
  "targetType": "msg",
100
78
  "statusVal": "",
101
79
  "statusType": "auto",
102
- "x": 760,
103
- "y": 380,
80
+ "x": 600,
81
+ "y": 340,
104
82
  "wires": []
105
83
  },
106
84
  {
107
- "id": "94c58ec5fd3ce89a",
85
+ "id": "c93a90f1145d7097",
108
86
  "type": "inject",
109
- "z": "78b174792ca9efaf",
110
- "g": "3aed22e8a8626b49",
87
+ "z": "2e6fd52cd06882a1",
88
+ "g": "b2325ede9b42d787",
111
89
  "name": "assistant payload",
112
90
  "props": [
113
- {
114
- "p": "topic",
115
- "vt": "str"
116
- },
117
91
  {
118
92
  "p": "payload"
119
93
  },
120
94
  {
121
95
  "p": "assistant.name",
122
- "v": "_node-red-openai-api-rag-example_",
96
+ "v": "_node-red-openai-api-file-search-example_",
123
97
  "vt": "str"
124
98
  },
125
99
  {
126
100
  "p": "assistant.model",
127
- "v": "gpt-3.5-turbo-1106",
101
+ "v": "gpt-4-turbo",
128
102
  "vt": "str"
129
103
  },
130
104
  {
131
105
  "p": "assistant.tools",
132
- "v": "[{\"type\":\"retrieval\"}]",
106
+ "v": "[{\"type\":\"file_search\"}]",
133
107
  "vt": "json"
134
108
  },
135
109
  {
@@ -147,69 +121,33 @@
147
121
  "crontab": "",
148
122
  "once": false,
149
123
  "onceDelay": 0.1,
150
- "topic": "retrieval",
151
- "payload": "[\"/path/to/my/file-1.txt\",\"/path/to/my/file-2.txt\"]",
124
+ "topic": "",
125
+ "payload": "[\"/path/to/my/assistant/file.1\",\"/path/to/my/assistant/file.2\"]",
152
126
  "payloadType": "json",
153
127
  "x": 220,
154
128
  "y": 220,
155
129
  "wires": [
156
130
  [
157
- "78bae2355d746f5b"
131
+ "fa3a845583809a96"
158
132
  ]
159
133
  ]
160
134
  },
161
135
  {
162
- "id": "78bae2355d746f5b",
163
- "type": "switch",
164
- "z": "78b174792ca9efaf",
165
- "g": "3aed22e8a8626b49",
166
- "name": "assistant type switch",
167
- "property": "topic",
168
- "propertyType": "msg",
169
- "rules": [
170
- {
171
- "t": "eq",
172
- "v": "retrieval",
173
- "vt": "str"
174
- },
175
- {
176
- "t": "else"
177
- }
178
- ],
179
- "checkall": "true",
180
- "repair": false,
181
- "outputs": 2,
182
- "x": 300,
183
- "y": 300,
184
- "wires": [
185
- [
186
- "7a825447030eb842"
187
- ],
188
- [
189
- "a319c0690ad183bc"
190
- ]
191
- ],
192
- "outputLabels": [
193
- "Document-enhanced Agent",
194
- "Standard Agent"
195
- ]
196
- },
197
- {
198
- "id": "16fd166e2cfe1aec",
136
+ "id": "80f2fcaea376e6fa",
199
137
  "type": "comment",
200
- "z": "78b174792ca9efaf",
201
- "g": "3aed22e8a8626b49",
202
- "name": "Document-Enhanced (RAG) Assistant",
138
+ "z": "2e6fd52cd06882a1",
139
+ "g": "b2325ede9b42d787",
140
+ "name": "File Search Assistant",
203
141
  "info": "",
204
- "x": 270,
142
+ "x": 220,
205
143
  "y": 180,
206
144
  "wires": []
207
145
  },
208
146
  {
209
- "id": "54cdefbcbbec117f",
147
+ "id": "7d03d073350147e7",
210
148
  "type": "inject",
211
- "z": "78b174792ca9efaf",
212
- "g": "3aed22e8a8626b49",
149
+ "z": "2e6fd52cd06882a1",
150
+ "g": "b2325ede9b42d787",
213
151
  "name": "assistant payload",
214
152
  "props": [
215
153
  {
@@ -219,7 +157,7 @@
219
157
  },
220
158
  {
221
159
  "p": "payload.model",
222
- "v": "gpt-4-1106-preview",
160
+ "v": "gpt-4-turbo",
223
161
  "vt": "str"
224
162
  },
225
163
  {
@@ -244,50 +182,29 @@
244
182
  "onceDelay": 0.1,
245
183
  "topic": "",
246
184
  "x": 220,
247
- "y": 380,
248
- "wires": [
249
- [
250
- "78bae2355d746f5b"
251
- ]
252
- ]
253
- },
254
- {
255
- "id": "e0007c022bce36b9",
256
- "type": "function",
257
- "z": "78b174792ca9efaf",
258
- "g": "3aed22e8a8626b49",
259
- "name": "structure assistant payload",
260
- "func": "// create an array of IDs from the fil upload response.\nconst file_ids = msg.payload.map(element => element.id);\n\n// attach the file IDs to the assistant.\nmsg.assistant.file_ids = file_ids;\n\nmsg.payload = msg.assistant;\n\nreturn msg;",
261
- "outputs": 1,
262
- "timeout": 0,
263
- "noerr": 0,
264
- "initialize": "",
265
- "finalize": "",
266
- "libs": [],
267
- "x": 1420,
268
- "y": 220,
185
+ "y": 340,
269
186
  "wires": [
270
187
  [
271
- "a319c0690ad183bc"
188
+ "5b0b2790637ab2b5"
272
189
  ]
273
190
  ]
274
191
  },
275
192
  {
276
- "id": "e5b83cdfc84c22f9",
193
+ "id": "6e0b6eedb964bb59",
277
194
  "type": "comment",
278
- "z": "78b174792ca9efaf",
279
- "g": "3aed22e8a8626b49",
195
+ "z": "2e6fd52cd06882a1",
196
+ "g": "b2325ede9b42d787",
280
197
  "name": "Standard Assistant",
281
198
  "info": "",
282
199
  "x": 210,
283
- "y": 420,
200
+ "y": 380,
284
201
  "wires": []
285
202
  },
286
203
  {
287
- "id": "7a825447030eb842",
204
+ "id": "fa3a845583809a96",
288
205
  "type": "split",
289
- "z": "78b174792ca9efaf",
290
- "g": "6ada9879e91ef156",
206
+ "z": "2e6fd52cd06882a1",
207
+ "g": "f478ebac3078686d",
291
208
  "name": "gather file details",
292
209
  "splt": "\\n",
293
210
  "spltType": "str",
@@ -295,59 +212,59 @@
295
212
  "arraySpltType": "len",
296
213
  "stream": false,
297
214
  "addname": "",
298
- "x": 570,
215
+ "x": 450,
299
216
  "y": 220,
300
217
  "wires": [
301
218
  [
302
- "da5c242d75d45b1a"
219
+ "47e765406b4b7af7"
303
220
  ]
304
221
  ]
305
222
  },
306
223
  {
307
- "id": "e78656f2a1db4141",
224
+ "id": "b7515492cea3f1fb",
308
225
  "type": "join",
309
- "z": "78b174792ca9efaf",
310
- "g": "6ada9879e91ef156",
311
- "name": "gather files",
312
- "mode": "auto",
313
- "build": "object",
314
- "property": "payload",
226
+ "z": "2e6fd52cd06882a1",
227
+ "g": "f478ebac3078686d",
228
+ "name": "gather file ids",
229
+ "mode": "custom",
230
+ "build": "array",
231
+ "property": "payload.id",
315
232
  "propertyType": "msg",
316
233
  "key": "topic",
317
234
  "joiner": "\\n",
318
235
  "joinerType": "str",
319
- "accumulate": true,
236
+ "accumulate": false,
320
237
  "timeout": "",
321
238
  "count": "",
322
239
  "reduceRight": false,
323
240
  "reduceExp": "",
324
241
  "reduceInit": "",
325
- "reduceInitType": "",
242
+ "reduceInitType": "num",
326
243
  "reduceFixup": "",
327
- "x": 1190,
244
+ "x": 1070,
328
245
  "y": 220,
329
246
  "wires": [
330
247
  [
331
- "e0007c022bce36b9"
248
+ "ab3a2c80ba3eacbd"
332
249
  ]
333
250
  ]
334
251
  },
335
252
  {
336
- "id": "a342bcf840361d49",
253
+ "id": "dc3d68ba96e95f34",
337
254
  "type": "comment",
338
- "z": "78b174792ca9efaf",
339
- "g": "6ada9879e91ef156",
340
- "name": "Upload Files",
255
+ "z": "2e6fd52cd06882a1",
256
+ "g": "f478ebac3078686d",
257
+ "name": "Vector Store Tasks",
341
258
  "info": "",
342
- "x": 550,
259
+ "x": 450,
343
260
  "y": 180,
344
261
  "wires": []
345
262
  },
346
263
  {
347
- "id": "da5c242d75d45b1a",
264
+ "id": "47e765406b4b7af7",
348
265
  "type": "function",
349
- "z": "78b174792ca9efaf",
350
- "g": "6ada9879e91ef156",
266
+ "z": "2e6fd52cd06882a1",
267
+ "g": "f478ebac3078686d",
351
268
  "name": "structure file payload",
352
269
  "func": "msg.payload = {\n \"file\": msg.payload,\n \"purpose\": \"assistants\",\n \"filename\": msg.filename\n};\nreturn msg;",
353
270
  "outputs": 1,
@@ -356,29 +273,18 @@
356
273
  "initialize": "",
357
274
  "finalize": "",
358
275
  "libs": [],
359
- "x": 800,
276
+ "x": 680,
360
277
  "y": 220,
361
278
  "wires": [
362
279
  [
363
- "faf6244b17ba1131"
280
+ "4bfcbf55e88e61dd"
364
281
  ]
365
282
  ]
366
283
  },
367
284
  {
368
- "id": "d0ed57739e76eba4",
285
+ "id": "a28af876056ff894",
369
286
  "type": "comment",
370
- "z": "78b174792ca9efaf",
371
- "g": "a08cc5475a20cc70",
372
- "name": "Create Assistant",
373
- "info": "",
374
- "x": 560,
375
- "y": 420,
376
- "wires": []
377
- },
378
- {
379
- "id": "e3812b47c1b7b918",
380
- "type": "comment",
381
- "z": "78b174792ca9efaf",
287
+ "z": "2e6fd52cd06882a1",
382
288
  "name": "Create Assistants",
383
289
  "info": "",
384
290
  "x": 180,
@@ -386,35 +292,96 @@
386
292
  "wires": []
387
293
  },
388
294
  {
389
- "id": "faf6244b17ba1131",
295
+ "id": "4bfcbf55e88e61dd",
390
296
  "type": "OpenAI API",
391
- "z": "78b174792ca9efaf",
392
- "g": "6ada9879e91ef156",
297
+ "z": "2e6fd52cd06882a1",
298
+ "g": "f478ebac3078686d",
393
299
  "name": "upload file",
300
+ "property": "payload",
301
+ "propertyType": "msg",
394
302
  "service": "",
395
303
  "method": "createFile",
396
- "x": 1010,
304
+ "x": 890,
397
305
  "y": 220,
398
306
  "wires": [
399
307
  [
400
- "e78656f2a1db4141"
308
+ "b7515492cea3f1fb"
401
309
  ]
402
310
  ]
403
311
  },
404
312
  {
405
- "id": "a319c0690ad183bc",
313
+ "id": "ab3a2c80ba3eacbd",
314
+ "type": "function",
315
+ "z": "2e6fd52cd06882a1",
316
+ "g": "f478ebac3078686d",
317
+ "name": "construct Assistant payload",
318
+ "func": "const {payload, assistant, ...newMsg} = msg;\nconst file_ids = payload.id;\n\nnewMsg.payload = assistant;\nnewMsg.payload.tool_resources = {\n \"file_search\": {\n \"vector_stores\": [{\"file_ids\": file_ids}]\n }\n};\n\nreturn newMsg;",
319
+ "outputs": 1,
320
+ "timeout": 0,
321
+ "noerr": 0,
322
+ "initialize": "",
323
+ "finalize": "",
324
+ "libs": [],
325
+ "x": 1300,
326
+ "y": 220,
327
+ "wires": [
328
+ [
329
+ "979ed3ff6205acfb"
330
+ ]
331
+ ]
332
+ },
333
+ {
334
+ "id": "979ed3ff6205acfb",
406
335
  "type": "OpenAI API",
407
- "z": "78b174792ca9efaf",
408
- "g": "a08cc5475a20cc70",
409
- "name": "create assistant",
336
+ "z": "2e6fd52cd06882a1",
337
+ "g": "b2325ede9b42d787",
338
+ "name": "Create Assistant",
339
+ "property": "payload",
340
+ "propertyType": "msg",
410
341
  "service": "",
411
342
  "method": "createAssistant",
412
- "x": 560,
413
- "y": 380,
343
+ "x": 1540,
344
+ "y": 220,
414
345
  "wires": [
415
346
  [
416
- "a1dd9dd38256bc37"
347
+ "b0c1fc6cafdb4e10"
417
348
  ]
418
349
  ]
350
+ },
351
+ {
352
+ "id": "5b0b2790637ab2b5",
353
+ "type": "OpenAI API",
354
+ "z": "2e6fd52cd06882a1",
355
+ "g": "b2325ede9b42d787",
356
+ "name": "Create Assistant",
357
+ "property": "payload",
358
+ "propertyType": "msg",
359
+ "service": "",
360
+ "method": "createAssistant",
361
+ "x": 420,
362
+ "y": 340,
363
+ "wires": [
364
+ [
365
+ "4a8b69a0d666e4b1"
366
+ ]
367
+ ]
368
+ },
369
+ {
370
+ "id": "b0c1fc6cafdb4e10",
371
+ "type": "debug",
372
+ "z": "2e6fd52cd06882a1",
373
+ "g": "b2325ede9b42d787",
374
+ "name": "response",
375
+ "active": true,
376
+ "tosidebar": true,
377
+ "console": false,
378
+ "tostatus": false,
379
+ "complete": "payload",
380
+ "targetType": "msg",
381
+ "statusVal": "",
382
+ "statusType": "auto",
383
+ "x": 1720,
384
+ "y": 220,
385
+ "wires": []
419
386
  }
420
387
  ]
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "id": "acd4d3697fd487ee",
4
4
  "type": "tab",
5
- "label": "Chat Example",
5
+ "label": "Image Chat Example",
6
6
  "disabled": false,
7
7
  "info": "",
8
8
  "env": []
@@ -32,7 +32,7 @@
32
32
  "props": [
33
33
  {
34
34
  "p": "payload.model",
35
- "v": "gpt-4-vision-preview",
35
+ "v": "gpt-4-turbo",
36
36
  "vt": "str"
37
37
  },
38
38
  {
@@ -74,7 +74,9 @@
74
74
  "type": "OpenAI API",
75
75
  "z": "acd4d3697fd487ee",
76
76
  "name": "chat completion",
77
- "service": "71860aa02b1968e3",
77
+ "property": "payload",
78
+ "propertyType": "msg",
79
+ "service": "",
78
80
  "method": "createChatCompletion",
79
81
  "x": 660,
80
82
  "y": 220,
@@ -20,8 +20,13 @@
20
20
  },
21
21
  {
22
22
  "p": "payload.model",
23
- "v": "text-embedding-ada-002",
23
+ "v": "text-embedding-3-small",
24
24
  "vt": "str"
25
+ },
26
+ {
27
+ "p": "payload.dimensions",
28
+ "v": "768",
29
+ "vt": "num"
25
30
  }
26
31
  ],
27
32
  "repeat": "",
@@ -59,7 +64,9 @@
59
64
  "type": "OpenAI API",
60
65
  "z": "70307b6cbfb7a7c8",
61
66
  "name": "create embeddings",
62
- "service": "39eba92e93450944",
67
+ "property": "payload",
68
+ "propertyType": "msg",
69
+ "service": "",
63
70
  "method": "createEmbedding",
64
71
  "x": 530,
65
72
  "y": 260,
@@ -46,7 +46,7 @@
46
46
  "tosidebar": true,
47
47
  "console": false,
48
48
  "tostatus": false,
49
- "complete": "payload.data",
49
+ "complete": "payload",
50
50
  "targetType": "msg",
51
51
  "statusVal": "",
52
52
  "statusType": "auto",
@@ -59,6 +59,8 @@
59
59
  "type": "OpenAI API",
60
60
  "z": "6920fb391b5cefcd",
61
61
  "name": "list fine-tuning jobs",
62
+ "property": "payload",
63
+ "propertyType": "msg",
62
64
  "service": "",
63
65
  "method": "listPaginatedFineTuningJobs",
64
66
  "x": 430,
@@ -25,7 +25,7 @@
25
25
  "props": [
26
26
  {
27
27
  "p": "payload.thread_id",
28
- "v": "thread_ShTYzF0LHfr4geWksTky4Gxu",
28
+ "v": "thread_id",
29
29
  "vt": "str"
30
30
  }
31
31
  ],
@@ -51,7 +51,7 @@
51
51
  "tosidebar": true,
52
52
  "console": false,
53
53
  "tostatus": false,
54
- "complete": "payload.data",
54
+ "complete": "payload",
55
55
  "targetType": "msg",
56
56
  "statusVal": "",
57
57
  "statusType": "auto",
@@ -64,6 +64,8 @@
64
64
  "type": "OpenAI API",
65
65
  "z": "47d8fb0adff5a6cc",
66
66
  "name": "list messages",
67
+ "property": "payload",
68
+ "propertyType": "msg",
67
69
  "service": "",
68
70
  "method": "listMessages",
69
71
  "x": 580,
@@ -12,7 +12,7 @@
12
12
  "type": "function",
13
13
  "z": "2610fa513fed33f5",
14
14
  "name": "filter owned models",
15
- "func": "// Assuming the payload is the array of objects\nlet data = msg.payload.data;\n\n// Filter the data\ndata = data.filter(item => {\n return item.owned_by !== 'system' && item.owned_by !== 'openai' && !item.owned_by.startsWith('openai-');\n});\n\n// Set the filtered data back to payload\nmsg.payload = data;\n\n// Return the message to be passed to the next node\nreturn msg;",
15
+ "func": "let models = msg.payload;\n\n// Filter the data\nconst myModels = models.filter(item => {\n return item.owned_by !== 'system' && item.owned_by !== 'openai' && !item.owned_by.startsWith('openai-');\n});\n\n// Set the filtered data back to payload\nmsg.payload = myModels;\n\n// Return the message to be passed to the next node\nreturn msg;",
16
16
  "outputs": 1,
17
17
  "timeout": 0,
18
18
  "noerr": 0,
@@ -32,6 +32,8 @@
32
32
  "type": "OpenAI API",
33
33
  "z": "2610fa513fed33f5",
34
34
  "name": "list models",
35
+ "property": "payload",
36
+ "propertyType": "msg",
35
37
  "service": "",
36
38
  "method": "listModels",
37
39
  "x": 390,
@@ -15,7 +15,7 @@
15
15
  "props": [
16
16
  {
17
17
  "p": "payload.thread_id",
18
- "v": "thread_z6eZuA1LGsRE6FvoSVcnq12q",
18
+ "v": "thread_id",
19
19
  "vt": "str"
20
20
  }
21
21
  ],
@@ -54,6 +54,8 @@
54
54
  "type": "OpenAI API",
55
55
  "z": "ec716b03b671e83a",
56
56
  "name": "retrieve thread",
57
+ "property": "payload",
58
+ "propertyType": "msg",
57
59
  "service": "",
58
60
  "method": "getThread",
59
61
  "x": 540,