node-red-contrib-custom-chatgpt
Version:
A Node-RED node that interacts with OpenAI machine learning models to generate text and image outputs like 'ChatGPT', 'DALL·E 2', and 'DALL·E 3'.
1,095 lines • 27.5 kB
JSON
[
{
"id": "acb2bb816d7b454b",
"type": "tab",
"label": "ChatGPT",
"disabled": false,
"info": "",
"env": []
},
{
"id": "86084a135dacac68",
"type": "junction",
"z": "acb2bb816d7b454b",
"x": 760,
"y": 520,
"wires": [
[
"1c5ba459c4b101f3"
]
]
},
{
"id": "c4f9dfdbd5d26711",
"type": "chatgpt",
"z": "acb2bb816d7b454b",
"name": "",
"API_KEY": "",
"Organization": "",
"topic": "completion",
"x": 520,
"y": 140,
"wires": [
[
"64dc49cdfc7ad13d"
]
]
},
{
"id": "4a4e42e0b484e289",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "completion:Write a story about a dog",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "completion",
"payload": "Write a story about a dog",
"payloadType": "str",
"x": 260,
"y": 100,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "ca6ee265beb31a91",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "image:a simple bird",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "format",
"v": "url",
"vt": "str"
},
{
"p": "size",
"v": "1024x1024",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "image",
"payload": "a simple bird",
"payloadType": "str",
"x": 310,
"y": 180,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "b692c28e07980c8e",
"type": "image viewer",
"z": "acb2bb816d7b454b",
"name": "",
"width": "1024",
"data": "payload",
"dataType": "msg",
"active": true,
"x": 850,
"y": 180,
"wires": [
[
"7ec2cd9208f12a67"
]
]
},
{
"id": "7ec2cd9208f12a67",
"type": "debug",
"z": "acb2bb816d7b454b",
"name": "debug image response",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1260,
"y": 180,
"wires": []
},
{
"id": "954361944f45a4d0",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "edit:reverse the text",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "last",
"v": "last",
"vt": "flow"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "edit",
"payload": "reverse the text",
"payloadType": "str",
"x": 310,
"y": 140,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "86fef8c1176f9ff4",
"type": "change",
"z": "acb2bb816d7b454b",
"name": "",
"rules": [
{
"t": "set",
"p": "last",
"pt": "flow",
"to": "payload",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 990,
"y": 100,
"wires": [
[
"081ed79769ffd2e7"
]
]
},
{
"id": "64dc49cdfc7ad13d",
"type": "switch",
"z": "acb2bb816d7b454b",
"name": "",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "edit",
"vt": "str"
},
{
"t": "eq",
"v": "completion",
"vt": "str"
},
{
"t": "eq",
"v": "turbo",
"vt": "str"
},
{
"t": "eq",
"v": "gpt4",
"vt": "str"
},
{
"t": "eq",
"v": "image",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 6,
"x": 670,
"y": 140,
"wires": [
[
"b9b7dc205872f024"
],
[
"b9b7dc205872f024"
],
[
"85d74e8b17c775c4"
],
[
"85d74e8b17c775c4"
],
[
"b692c28e07980c8e"
],
[
"27b0d5836f1360ec"
]
]
},
{
"id": "b9b7dc205872f024",
"type": "string",
"z": "acb2bb816d7b454b",
"name": "",
"methods": [
{
"name": "collapseWhitespace",
"params": []
}
],
"prop": "payload",
"propout": "payload",
"object": "msg",
"objectout": "msg",
"x": 850,
"y": 100,
"wires": [
[
"86fef8c1176f9ff4"
]
]
},
{
"id": "081ed79769ffd2e7",
"type": "debug",
"z": "acb2bb816d7b454b",
"name": "debug completion/edit response",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1290,
"y": 100,
"wires": []
},
{
"id": "7947221db9519f9a",
"type": "template",
"z": "acb2bb816d7b454b",
"name": "proofread input",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "Proofread the following text: `{{payload}}`",
"output": "str",
"x": 560,
"y": 520,
"wires": [
[
"86084a135dacac68"
]
]
},
{
"id": "5362b83c594b3902",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "input text to proofread",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "I ate some apples four dinner last thursday. they were very good.",
"payloadType": "str",
"x": 300,
"y": 520,
"wires": [
[
"7947221db9519f9a"
]
]
},
{
"id": "27b0d5836f1360ec",
"type": "debug",
"z": "acb2bb816d7b454b",
"name": "debug prompt outputs",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 580,
"y": 220,
"wires": []
},
{
"id": "513138ef8ff6dd29",
"type": "template",
"z": "acb2bb816d7b454b",
"name": "generate d&d npc description",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "Generate a high-quality Dungeons and Dragons NPC named {{name}} that is a {{gender}} {{race}} {{class}} {{occupation}}.",
"output": "str",
"x": 600,
"y": 560,
"wires": [
[
"86084a135dacac68"
]
]
},
{
"id": "1c5ba459c4b101f3",
"type": "change",
"z": "acb2bb816d7b454b",
"name": "set msg.topic to completion",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "completion",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 280,
"y": 460,
"wires": [
[
"c4f9dfdbd5d26711",
"53b05f881b1497c2"
]
]
},
{
"id": "b54243750128cf7c",
"type": "template",
"z": "acb2bb816d7b454b",
"name": "generate d&d npc stat block",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "Generate a {{format}} for a high-quality Dungeons and Dragons 5e NPC that is a level {{level}} {{gender}} {{race}} {{class}} {{occupation}}.",
"output": "str",
"x": 600,
"y": 600,
"wires": [
[
"86084a135dacac68"
]
]
},
{
"id": "de3c52ae9c0d7262",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "input npc characteristics",
"props": [
{
"p": "payload"
},
{
"p": "gender",
"v": "Female",
"vt": "str"
},
{
"p": "race",
"v": "Dwarf",
"vt": "str"
},
{
"p": "class",
"v": "Cleric",
"vt": "str"
},
{
"p": "occupation",
"v": "Blacksmith",
"vt": "str"
},
{
"p": "level",
"v": "5",
"vt": "str"
},
{
"p": "format",
"v": "stat block",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "str",
"x": 300,
"y": 600,
"wires": [
[
"b54243750128cf7c"
]
]
},
{
"id": "d4171b19f095210f",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "input npc characteristics",
"props": [
{
"p": "payload"
},
{
"p": "gender",
"v": "Female",
"vt": "str"
},
{
"p": "race",
"v": "Dwarf",
"vt": "str"
},
{
"p": "class",
"v": "Cleric",
"vt": "str"
},
{
"p": "occupation",
"v": "Blacksmith",
"vt": "str"
},
{
"p": "level",
"v": "5",
"vt": "str"
},
{
"p": "name",
"v": "Merelda Ironheart",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "str",
"x": 300,
"y": 560,
"wires": [
[
"513138ef8ff6dd29"
]
]
},
{
"id": "775f1d12592ed6dd",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "turbo:Write a story about an Elephant",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "history",
"v": "#:(memoryOnly)::history",
"vt": "flow"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "turbo",
"payload": "Write a story about an Elephant.",
"payloadType": "str",
"x": 250,
"y": 280,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "bb68b4b88105b176",
"type": "change",
"z": "acb2bb816d7b454b",
"name": "set flow.last & flow.history",
"rules": [
{
"t": "set",
"p": "last",
"pt": "flow",
"to": "payload",
"tot": "msg",
"dc": true
},
{
"t": "set",
"p": "#:(memoryOnly)::history",
"pt": "flow",
"to": "history",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1030,
"y": 140,
"wires": [
[
"78967db3112b3747"
]
]
},
{
"id": "85d74e8b17c775c4",
"type": "string",
"z": "acb2bb816d7b454b",
"name": "",
"methods": [
{
"name": "collapseWhitespace",
"params": []
}
],
"prop": "payload",
"propout": "payload",
"object": "msg",
"objectout": "msg",
"x": 850,
"y": 140,
"wires": [
[
"bb68b4b88105b176"
]
]
},
{
"id": "78967db3112b3747",
"type": "debug",
"z": "acb2bb816d7b454b",
"name": "debug \"turbo-gpt4\" response",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1280,
"y": 140,
"wires": []
},
{
"id": "4a62f73d7954a1d6",
"type": "change",
"z": "acb2bb816d7b454b",
"name": "reset flow.history",
"rules": [
{
"t": "set",
"p": "#:(memoryOnly)::history",
"pt": "flow",
"to": "history",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 40,
"wires": [
[
"721e7348f388d550"
]
]
},
{
"id": "5d94b959d077a956",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "Reset convesation history",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "history",
"v": "[]",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "turbo",
"payload": "",
"payloadType": "str",
"x": 290,
"y": 40,
"wires": [
[
"4a62f73d7954a1d6"
]
]
},
{
"id": "721e7348f388d550",
"type": "debug",
"z": "acb2bb816d7b454b",
"name": "debug reset",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1230,
"y": 40,
"wires": []
},
{
"id": "d5d45a15de65ea5f",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "turbo:Change it to be about a dog.",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "history",
"v": "#:(memoryOnly)::history",
"vt": "flow"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "turbo",
"payload": "Change it to be about a dog.",
"payloadType": "str",
"x": 260,
"y": 360,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "cea4aa1bc33d8e8f",
"type": "comment",
"z": "acb2bb816d7b454b",
"name": "Using templates to preset model behavior",
"info": "",
"x": 240,
"y": 420,
"wires": []
},
{
"id": "26965055703e793c",
"type": "comment",
"z": "acb2bb816d7b454b",
"name": "Starting a conversation [turbo]",
"info": "",
"x": 280,
"y": 240,
"wires": []
},
{
"id": "e0522446ea1b2da3",
"type": "comment",
"z": "acb2bb816d7b454b",
"name": "Continuing a conversation [turbo]",
"info": "",
"x": 270,
"y": 320,
"wires": []
},
{
"id": "35fc5b252e1a5748",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "set chatgpt node Topic to `completion` then test",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Write a story about a dog",
"payloadType": "str",
"x": 220,
"y": 840,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "5f1abed24f071a98",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "set chatgpt node Topic to `image` then test",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "a simple bird",
"payloadType": "str",
"x": 240,
"y": 920,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "949ea24392a47f31",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "set chatgpt node Topic to `edit` then test",
"props": [
{
"p": "payload"
},
{
"p": "last",
"v": "last",
"vt": "flow"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Reverse the following text ",
"payloadType": "str",
"x": 250,
"y": 880,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "db32505ba2d95fa3",
"type": "comment",
"z": "acb2bb816d7b454b",
"name": "Set Topic in node edit dialog first",
"info": "",
"x": 270,
"y": 800,
"wires": []
},
{
"id": "53b05f881b1497c2",
"type": "debug",
"z": "acb2bb816d7b454b",
"name": "debug prompt inputs",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 580,
"y": 460,
"wires": []
},
{
"id": "f0156e46f013f9cd",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "completion:Write a story about a msg.suffix",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "suffix",
"v": "dog",
"vt": "str"
},
{
"p": "n",
"v": "1",
"vt": "num"
},
{
"p": "temperature",
"v": "1",
"vt": "num"
},
{
"p": "presence_penalty",
"v": "0.2",
"vt": "num"
},
{
"p": "frequency_penalty",
"v": "0.2",
"vt": "num"
},
{
"p": "best_of",
"v": "1",
"vt": "num"
},
{
"p": "max_tokens",
"v": "3000",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "completion",
"payload": "Write a story about a ",
"payloadType": "str",
"x": 240,
"y": 700,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "f0f036eaedeee02c",
"type": "comment",
"z": "acb2bb816d7b454b",
"name": "Using optional message properties",
"info": "",
"x": 260,
"y": 660,
"wires": []
},
{
"id": "6a40a782c5e2a882",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "completion:Write a story about a dog",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "n",
"v": "1",
"vt": "num"
},
{
"p": "top_p",
"v": "1",
"vt": "num"
},
{
"p": "presence_penalty",
"v": "2",
"vt": "num"
},
{
"p": "frequency_penalty",
"v": "2",
"vt": "num"
},
{
"p": "echo",
"v": "true",
"vt": "bool"
},
{
"p": "max_tokens",
"v": "3000",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "completion",
"payload": "Write a story about a dog",
"payloadType": "str",
"x": 260,
"y": 740,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "71fe4d1fbbecd759",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "set chatgpt node Topic to `turbo` then test",
"props": [
{
"p": "payload"
},
{
"p": "max_tokens",
"v": "3000",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Respond only with valid JavaScript syntax, generate a minimized JavaScript function that calculates the average of an array of numbers. The function should take an array of numbers as input and return the average as output. The generated code should be a self-contained function that can be used directly in the next Node-RED node. The function should take a single parameter, which is an array of numbers, and return the average of the numbers in the array. It should not rely on external dependencies or global variables.",
"payloadType": "str",
"x": 240,
"y": 960,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
},
{
"id": "601eb14380de5503",
"type": "inject",
"z": "acb2bb816d7b454b",
"name": "set chatgpt node Topic to `gpt4` then test",
"props": [
{
"p": "payload"
},
{
"p": "max_tokens",
"v": "3000",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Respond only with valid JavaScript syntax, generate a minimized JavaScript function that calculates the average of an array of numbers. The function should take an array of numbers as input and return the average as output. The generated code should be a self-contained function that can be used directly in the next Node-RED node. The function should take a single parameter, which is an array of numbers, and return the average of the numbers in the array. It should not rely on external dependencies or global variables.",
"payloadType": "str",
"x": 240,
"y": 1000,
"wires": [
[
"c4f9dfdbd5d26711"
]
]
}
]