@inductiv/node-red-openai-api 0.1.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.
@@ -0,0 +1,87 @@
1
+ [
2
+ {
3
+ "id": "acd4d3697fd487ee",
4
+ "type": "tab",
5
+ "label": "Chat Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "57cef9ebcf8dfb98",
12
+ "type": "debug",
13
+ "z": "acd4d3697fd487ee",
14
+ "name": "response",
15
+ "active": true,
16
+ "tosidebar": true,
17
+ "console": false,
18
+ "tostatus": false,
19
+ "complete": "payload.choices[0].message.content",
20
+ "targetType": "msg",
21
+ "statusVal": "",
22
+ "statusType": "auto",
23
+ "x": 860,
24
+ "y": 220,
25
+ "wires": []
26
+ },
27
+ {
28
+ "id": "c390a96f44686f5c",
29
+ "type": "inject",
30
+ "z": "acd4d3697fd487ee",
31
+ "name": "chat payload",
32
+ "props": [
33
+ {
34
+ "p": "payload.model",
35
+ "v": "gpt-4-vision-preview",
36
+ "vt": "str"
37
+ },
38
+ {
39
+ "p": "payload.max_tokens",
40
+ "v": "1024",
41
+ "vt": "num"
42
+ },
43
+ {
44
+ "p": "payload.messages",
45
+ "v": "[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"Hi there! Do I have carrots in my fridge and if so, can you tell me where I can find them? Thanks!\"},{\"type\":\"image_url\",\"image_url\":{\"url\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Open_refrigerator_with_food_at_night.jpg/1280px-Open_refrigerator_with_food_at_night.jpg\"}}]}]",
46
+ "vt": "json"
47
+ }
48
+ ],
49
+ "repeat": "",
50
+ "crontab": "",
51
+ "once": false,
52
+ "onceDelay": 0.1,
53
+ "topic": "",
54
+ "x": 450,
55
+ "y": 220,
56
+ "wires": [
57
+ [
58
+ "765e638b2f084d76"
59
+ ]
60
+ ]
61
+ },
62
+ {
63
+ "id": "b6f7ef395f45bc6f",
64
+ "type": "comment",
65
+ "z": "acd4d3697fd487ee",
66
+ "name": "Chat about an image.",
67
+ "info": "",
68
+ "x": 460,
69
+ "y": 180,
70
+ "wires": []
71
+ },
72
+ {
73
+ "id": "765e638b2f084d76",
74
+ "type": "openai-api",
75
+ "z": "acd4d3697fd487ee",
76
+ "name": "chat completion",
77
+ "service": "71860aa02b1968e3",
78
+ "method": "createChatCompletion",
79
+ "x": 660,
80
+ "y": 220,
81
+ "wires": [
82
+ [
83
+ "57cef9ebcf8dfb98"
84
+ ]
85
+ ]
86
+ }
87
+ ]
@@ -0,0 +1,72 @@
1
+ [
2
+ {
3
+ "id": "70307b6cbfb7a7c8",
4
+ "type": "tab",
5
+ "label": "Embeddings Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "8b09265787f70886",
12
+ "type": "inject",
13
+ "z": "70307b6cbfb7a7c8",
14
+ "name": "embedding payload",
15
+ "props": [
16
+ {
17
+ "p": "payload.input",
18
+ "v": "The food was great, and the service was too! 💥",
19
+ "vt": "str"
20
+ },
21
+ {
22
+ "p": "payload.model",
23
+ "v": "text-embedding-ada-002",
24
+ "vt": "str"
25
+ }
26
+ ],
27
+ "repeat": "",
28
+ "crontab": "",
29
+ "once": false,
30
+ "onceDelay": 0.1,
31
+ "topic": "",
32
+ "x": 290,
33
+ "y": 260,
34
+ "wires": [
35
+ [
36
+ "5096e563fd5b02cf"
37
+ ]
38
+ ]
39
+ },
40
+ {
41
+ "id": "ddf89bf74f316e1f",
42
+ "type": "debug",
43
+ "z": "70307b6cbfb7a7c8",
44
+ "name": "response",
45
+ "active": true,
46
+ "tosidebar": true,
47
+ "console": false,
48
+ "tostatus": false,
49
+ "complete": "payload.data[0].embedding",
50
+ "targetType": "msg",
51
+ "statusVal": "",
52
+ "statusType": "auto",
53
+ "x": 740,
54
+ "y": 260,
55
+ "wires": []
56
+ },
57
+ {
58
+ "id": "5096e563fd5b02cf",
59
+ "type": "openai-api",
60
+ "z": "70307b6cbfb7a7c8",
61
+ "name": "create embeddings",
62
+ "service": "39eba92e93450944",
63
+ "method": "createEmbedding",
64
+ "x": 530,
65
+ "y": 260,
66
+ "wires": [
67
+ [
68
+ "ddf89bf74f316e1f"
69
+ ]
70
+ ]
71
+ }
72
+ ]
@@ -0,0 +1,72 @@
1
+ [
2
+ {
3
+ "id": "1e45d9e751f7d036",
4
+ "type": "tab",
5
+ "label": "Files Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "72d0fa390cfdbe59",
12
+ "type": "comment",
13
+ "z": "1e45d9e751f7d036",
14
+ "name": "Returns a list of files that belong to the user's organization.",
15
+ "info": "",
16
+ "x": 330,
17
+ "y": 220,
18
+ "wires": []
19
+ },
20
+ {
21
+ "id": "a27ea2a2de405820",
22
+ "type": "inject",
23
+ "z": "1e45d9e751f7d036",
24
+ "name": "",
25
+ "props": [],
26
+ "repeat": "",
27
+ "crontab": "",
28
+ "once": false,
29
+ "onceDelay": 0.1,
30
+ "topic": "",
31
+ "x": 155,
32
+ "y": 280,
33
+ "wires": [
34
+ [
35
+ "b2eb824897e04b08"
36
+ ]
37
+ ],
38
+ "l": false
39
+ },
40
+ {
41
+ "id": "1cc99dce76439ced",
42
+ "type": "debug",
43
+ "z": "1e45d9e751f7d036",
44
+ "name": "response",
45
+ "active": true,
46
+ "tosidebar": true,
47
+ "console": false,
48
+ "tostatus": false,
49
+ "complete": "payload.data",
50
+ "targetType": "msg",
51
+ "statusVal": "",
52
+ "statusType": "auto",
53
+ "x": 460,
54
+ "y": 280,
55
+ "wires": []
56
+ },
57
+ {
58
+ "id": "b2eb824897e04b08",
59
+ "type": "openai-api",
60
+ "z": "1e45d9e751f7d036",
61
+ "name": "list files",
62
+ "service": "",
63
+ "method": "listFiles",
64
+ "x": 280,
65
+ "y": 280,
66
+ "wires": [
67
+ [
68
+ "1cc99dce76439ced"
69
+ ]
70
+ ]
71
+ }
72
+ ]
@@ -0,0 +1,72 @@
1
+ [
2
+ {
3
+ "id": "6920fb391b5cefcd",
4
+ "type": "tab",
5
+ "label": "Fine-tuning Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "3cf1ce601d097456",
12
+ "type": "inject",
13
+ "z": "6920fb391b5cefcd",
14
+ "name": "",
15
+ "props": [],
16
+ "repeat": "",
17
+ "crontab": "",
18
+ "once": false,
19
+ "onceDelay": 0.1,
20
+ "topic": "",
21
+ "x": 275,
22
+ "y": 260,
23
+ "wires": [
24
+ [
25
+ "bdaf36c829550e41"
26
+ ]
27
+ ],
28
+ "l": false
29
+ },
30
+ {
31
+ "id": "91ef7edeb8621f4e",
32
+ "type": "comment",
33
+ "z": "6920fb391b5cefcd",
34
+ "name": "List your organization's fine-tuning jobs",
35
+ "info": "",
36
+ "x": 390,
37
+ "y": 200,
38
+ "wires": []
39
+ },
40
+ {
41
+ "id": "fadc3f2cbe276ec2",
42
+ "type": "debug",
43
+ "z": "6920fb391b5cefcd",
44
+ "name": "response",
45
+ "active": true,
46
+ "tosidebar": true,
47
+ "console": false,
48
+ "tostatus": false,
49
+ "complete": "payload.data",
50
+ "targetType": "msg",
51
+ "statusVal": "",
52
+ "statusType": "auto",
53
+ "x": 620,
54
+ "y": 260,
55
+ "wires": []
56
+ },
57
+ {
58
+ "id": "bdaf36c829550e41",
59
+ "type": "openai-api",
60
+ "z": "6920fb391b5cefcd",
61
+ "name": "list fine-tuning jobs",
62
+ "service": "",
63
+ "method": "listPaginatedFineTuningJobs",
64
+ "x": 430,
65
+ "y": 260,
66
+ "wires": [
67
+ [
68
+ "fadc3f2cbe276ec2"
69
+ ]
70
+ ]
71
+ }
72
+ ]
@@ -0,0 +1,82 @@
1
+ [
2
+ {
3
+ "id": "8b5b83e806871f8b",
4
+ "type": "tab",
5
+ "label": "Images Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "e619113e002286a4",
12
+ "type": "inject",
13
+ "z": "8b5b83e806871f8b",
14
+ "name": "image payload",
15
+ "props": [
16
+ {
17
+ "p": "payload.prompt",
18
+ "v": "A cute baby sea otter",
19
+ "vt": "str"
20
+ },
21
+ {
22
+ "p": "payload.model",
23
+ "v": "dall-e-3",
24
+ "vt": "str"
25
+ }
26
+ ],
27
+ "repeat": "",
28
+ "crontab": "",
29
+ "once": false,
30
+ "onceDelay": 0.1,
31
+ "topic": "",
32
+ "x": 280,
33
+ "y": 200,
34
+ "wires": [
35
+ [
36
+ "979e1bb6732cc292"
37
+ ]
38
+ ]
39
+ },
40
+ {
41
+ "id": "b83c3be8fd9e1a43",
42
+ "type": "debug",
43
+ "z": "8b5b83e806871f8b",
44
+ "name": "response",
45
+ "active": true,
46
+ "tosidebar": true,
47
+ "console": false,
48
+ "tostatus": false,
49
+ "complete": "payload",
50
+ "targetType": "msg",
51
+ "statusVal": "",
52
+ "statusType": "auto",
53
+ "x": 680,
54
+ "y": 200,
55
+ "wires": []
56
+ },
57
+ {
58
+ "id": "8f836da49c19b6f9",
59
+ "type": "comment",
60
+ "z": "8b5b83e806871f8b",
61
+ "name": "Creates an image given a prompt.",
62
+ "info": "",
63
+ "x": 320,
64
+ "y": 140,
65
+ "wires": []
66
+ },
67
+ {
68
+ "id": "979e1bb6732cc292",
69
+ "type": "openai-api",
70
+ "z": "8b5b83e806871f8b",
71
+ "name": "create image",
72
+ "service": "",
73
+ "method": "createImage",
74
+ "x": 490,
75
+ "y": 200,
76
+ "wires": [
77
+ [
78
+ "b83c3be8fd9e1a43"
79
+ ]
80
+ ]
81
+ }
82
+ ]
@@ -0,0 +1,77 @@
1
+ [
2
+ {
3
+ "id": "47d8fb0adff5a6cc",
4
+ "type": "tab",
5
+ "label": "Messages Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "e2875b512fa3e36a",
12
+ "type": "comment",
13
+ "z": "47d8fb0adff5a6cc",
14
+ "name": "Returns a list of messages for a given thread.",
15
+ "info": "",
16
+ "x": 430,
17
+ "y": 160,
18
+ "wires": []
19
+ },
20
+ {
21
+ "id": "25b586ac72069905",
22
+ "type": "inject",
23
+ "z": "47d8fb0adff5a6cc",
24
+ "name": "messages payload",
25
+ "props": [
26
+ {
27
+ "p": "payload.thread_id",
28
+ "v": "thread_ShTYzF0LHfr4geWksTky4Gxu",
29
+ "vt": "str"
30
+ }
31
+ ],
32
+ "repeat": "",
33
+ "crontab": "",
34
+ "once": false,
35
+ "onceDelay": 0.1,
36
+ "topic": "",
37
+ "x": 370,
38
+ "y": 220,
39
+ "wires": [
40
+ [
41
+ "932b2514509c22ea"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "1330d46beba61bc0",
47
+ "type": "debug",
48
+ "z": "47d8fb0adff5a6cc",
49
+ "name": "response",
50
+ "active": true,
51
+ "tosidebar": true,
52
+ "console": false,
53
+ "tostatus": false,
54
+ "complete": "payload.data",
55
+ "targetType": "msg",
56
+ "statusVal": "",
57
+ "statusType": "auto",
58
+ "x": 760,
59
+ "y": 220,
60
+ "wires": []
61
+ },
62
+ {
63
+ "id": "932b2514509c22ea",
64
+ "type": "openai-api",
65
+ "z": "47d8fb0adff5a6cc",
66
+ "name": "list messages",
67
+ "service": "",
68
+ "method": "listMessages",
69
+ "x": 580,
70
+ "y": 220,
71
+ "wires": [
72
+ [
73
+ "1330d46beba61bc0"
74
+ ]
75
+ ]
76
+ }
77
+ ]
@@ -0,0 +1,92 @@
1
+ [
2
+ {
3
+ "id": "2610fa513fed33f5",
4
+ "type": "tab",
5
+ "label": "Models Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "a399823d7a30b91e",
12
+ "type": "function",
13
+ "z": "2610fa513fed33f5",
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;",
16
+ "outputs": 1,
17
+ "timeout": 0,
18
+ "noerr": 0,
19
+ "initialize": "",
20
+ "finalize": "",
21
+ "libs": [],
22
+ "x": 590,
23
+ "y": 280,
24
+ "wires": [
25
+ [
26
+ "a60b28cb82cd91d5"
27
+ ]
28
+ ]
29
+ },
30
+ {
31
+ "id": "535006a3343dacc3",
32
+ "type": "openai-api",
33
+ "z": "2610fa513fed33f5",
34
+ "name": "list models",
35
+ "service": "",
36
+ "method": "listModels",
37
+ "x": 390,
38
+ "y": 280,
39
+ "wires": [
40
+ [
41
+ "a399823d7a30b91e"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "94386b0ce40460f3",
47
+ "type": "inject",
48
+ "z": "2610fa513fed33f5",
49
+ "name": "",
50
+ "props": [],
51
+ "repeat": "",
52
+ "crontab": "",
53
+ "once": false,
54
+ "onceDelay": 0.1,
55
+ "topic": "",
56
+ "x": 275,
57
+ "y": 280,
58
+ "wires": [
59
+ [
60
+ "535006a3343dacc3"
61
+ ]
62
+ ],
63
+ "l": false
64
+ },
65
+ {
66
+ "id": "a60b28cb82cd91d5",
67
+ "type": "debug",
68
+ "z": "2610fa513fed33f5",
69
+ "name": "response",
70
+ "active": true,
71
+ "tosidebar": true,
72
+ "console": false,
73
+ "tostatus": false,
74
+ "complete": "payload",
75
+ "targetType": "msg",
76
+ "statusVal": "",
77
+ "statusType": "auto",
78
+ "x": 780,
79
+ "y": 280,
80
+ "wires": []
81
+ },
82
+ {
83
+ "id": "d5eee6b5ac4907f2",
84
+ "type": "comment",
85
+ "z": "2610fa513fed33f5",
86
+ "name": "List owned models (e.g., fine-tuned models).",
87
+ "info": "",
88
+ "x": 410,
89
+ "y": 240,
90
+ "wires": []
91
+ }
92
+ ]
@@ -0,0 +1,77 @@
1
+ [
2
+ {
3
+ "id": "4e4adf62cc07faa5",
4
+ "type": "tab",
5
+ "label": "Moderations Example",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "1397cceabb2fc6e5",
12
+ "type": "inject",
13
+ "z": "4e4adf62cc07faa5",
14
+ "name": "moderation payload",
15
+ "props": [
16
+ {
17
+ "p": "payload.input",
18
+ "v": "Today is a wonderful day.",
19
+ "vt": "str"
20
+ }
21
+ ],
22
+ "repeat": "",
23
+ "crontab": "",
24
+ "once": false,
25
+ "onceDelay": 0.1,
26
+ "topic": "",
27
+ "x": 290,
28
+ "y": 300,
29
+ "wires": [
30
+ [
31
+ "58bfb89e83e4cc78"
32
+ ]
33
+ ]
34
+ },
35
+ {
36
+ "id": "2456728dbe58d36a",
37
+ "type": "debug",
38
+ "z": "4e4adf62cc07faa5",
39
+ "name": "response",
40
+ "active": true,
41
+ "tosidebar": true,
42
+ "console": false,
43
+ "tostatus": false,
44
+ "complete": "payload.results",
45
+ "targetType": "msg",
46
+ "statusVal": "",
47
+ "statusType": "auto",
48
+ "x": 720,
49
+ "y": 300,
50
+ "wires": []
51
+ },
52
+ {
53
+ "id": "58bfb89e83e4cc78",
54
+ "type": "openai-api",
55
+ "z": "4e4adf62cc07faa5",
56
+ "name": "create moderation",
57
+ "service": "",
58
+ "method": "createModeration",
59
+ "x": 510,
60
+ "y": 300,
61
+ "wires": [
62
+ [
63
+ "2456728dbe58d36a"
64
+ ]
65
+ ]
66
+ },
67
+ {
68
+ "id": "04c7ba9de965df5d",
69
+ "type": "comment",
70
+ "z": "4e4adf62cc07faa5",
71
+ "name": "Classifies if text violates OpenAI's Content Policy",
72
+ "info": "",
73
+ "x": 360,
74
+ "y": 240,
75
+ "wires": []
76
+ }
77
+ ]