@inductiv/node-red-openai-api
Version:
Enhance your Node-RED projects with advanced AI capabilities.
387 lines • 9.85 kB
JSON
[
{
"id": "2e6fd52cd06882a1",
"type": "tab",
"label": "Assistants V2 Examples",
"disabled": false,
"info": "",
"env": []
},
{
"id": "b2325ede9b42d787",
"type": "group",
"z": "2e6fd52cd06882a1",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"4a8b69a0d666e4b1",
"c93a90f1145d7097",
"80f2fcaea376e6fa",
"7d03d073350147e7",
"6e0b6eedb964bb59",
"f478ebac3078686d",
"979ed3ff6205acfb",
"5b0b2790637ab2b5",
"b0c1fc6cafdb4e10"
],
"x": 94,
"y": 113,
"w": 1732,
"h": 308
},
{
"id": "f478ebac3078686d",
"type": "group",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"fa3a845583809a96",
"b7515492cea3f1fb",
"dc3d68ba96e95f34",
"47e765406b4b7af7",
"4bfcbf55e88e61dd",
"ab3a2c80ba3eacbd"
],
"x": 334,
"y": 139,
"w": 1112,
"h": 122
},
{
"id": "4a8b69a0d666e4b1",
"type": "debug",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "response",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 600,
"y": 340,
"wires": []
},
{
"id": "c93a90f1145d7097",
"type": "inject",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "assistant payload",
"props": [
{
"p": "payload"
},
{
"p": "assistant.name",
"v": "_node-red-openai-api-file-search-example_",
"vt": "str"
},
{
"p": "assistant.model",
"v": "gpt-4-turbo",
"vt": "str"
},
{
"p": "assistant.tools",
"v": "[{\"type\":\"file_search\"}]",
"vt": "json"
},
{
"p": "assistant.description",
"v": "My helpful assistant.",
"vt": "str"
},
{
"p": "assistant.instructions",
"v": "You are a helpful assistant with access to files that I share with you.",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[\"/path/to/my/assistant/file.1\",\"/path/to/my/assistant/file.2\"]",
"payloadType": "json",
"x": 220,
"y": 220,
"wires": [
[
"fa3a845583809a96"
]
]
},
{
"id": "80f2fcaea376e6fa",
"type": "comment",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "File Search Assistant",
"info": "",
"x": 220,
"y": 180,
"wires": []
},
{
"id": "7d03d073350147e7",
"type": "inject",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "assistant payload",
"props": [
{
"p": "payload.name",
"v": "_node-red-openai-api-example_",
"vt": "str"
},
{
"p": "payload.model",
"v": "gpt-4-turbo",
"vt": "str"
},
{
"p": "payload.tools",
"v": "[{\"type\":\"code_interpreter\"}]",
"vt": "json"
},
{
"p": "payload.description",
"v": "My helpful standard assistant.",
"vt": "str"
},
{
"p": "payload.instructions",
"v": "You are a helpful assistant.",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 220,
"y": 340,
"wires": [
[
"5b0b2790637ab2b5"
]
]
},
{
"id": "6e0b6eedb964bb59",
"type": "comment",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "Standard Assistant",
"info": "",
"x": 210,
"y": 380,
"wires": []
},
{
"id": "fa3a845583809a96",
"type": "split",
"z": "2e6fd52cd06882a1",
"g": "f478ebac3078686d",
"name": "gather file details",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 450,
"y": 220,
"wires": [
[
"47e765406b4b7af7"
]
]
},
{
"id": "b7515492cea3f1fb",
"type": "join",
"z": "2e6fd52cd06882a1",
"g": "f478ebac3078686d",
"name": "gather file ids",
"mode": "custom",
"build": "array",
"property": "payload.id",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 1070,
"y": 220,
"wires": [
[
"ab3a2c80ba3eacbd"
]
]
},
{
"id": "dc3d68ba96e95f34",
"type": "comment",
"z": "2e6fd52cd06882a1",
"g": "f478ebac3078686d",
"name": "Vector Store Tasks",
"info": "",
"x": 450,
"y": 180,
"wires": []
},
{
"id": "47e765406b4b7af7",
"type": "function",
"z": "2e6fd52cd06882a1",
"g": "f478ebac3078686d",
"name": "structure file payload",
"func": "msg.payload = {\n \"file\": msg.payload,\n \"purpose\": \"assistants\",\n \"filename\": msg.filename\n};\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 680,
"y": 220,
"wires": [
[
"4bfcbf55e88e61dd"
]
]
},
{
"id": "a28af876056ff894",
"type": "comment",
"z": "2e6fd52cd06882a1",
"name": "Create Assistants",
"info": "",
"x": 180,
"y": 80,
"wires": []
},
{
"id": "4bfcbf55e88e61dd",
"type": "OpenAI API",
"z": "2e6fd52cd06882a1",
"g": "f478ebac3078686d",
"name": "upload file",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "createFile",
"x": 890,
"y": 220,
"wires": [
[
"b7515492cea3f1fb"
]
]
},
{
"id": "ab3a2c80ba3eacbd",
"type": "function",
"z": "2e6fd52cd06882a1",
"g": "f478ebac3078686d",
"name": "construct Assistant payload",
"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;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1300,
"y": 220,
"wires": [
[
"979ed3ff6205acfb"
]
]
},
{
"id": "979ed3ff6205acfb",
"type": "OpenAI API",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "Create Assistant",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "createAssistant",
"x": 1540,
"y": 220,
"wires": [
[
"b0c1fc6cafdb4e10"
]
]
},
{
"id": "5b0b2790637ab2b5",
"type": "OpenAI API",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "Create Assistant",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "createAssistant",
"x": 420,
"y": 340,
"wires": [
[
"4a8b69a0d666e4b1"
]
]
},
{
"id": "b0c1fc6cafdb4e10",
"type": "debug",
"z": "2e6fd52cd06882a1",
"g": "b2325ede9b42d787",
"name": "response",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1720,
"y": 220,
"wires": []
}
]