# \[Announce\] node-red-contrib-custom-chatgpt

**URL:** <https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644>\
**Category:** Share Your Nodes\
**Created:** [23 February 2023 17:09 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644 "2023-02-23T17:09:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [23 February 2023 17:09 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644/1 "2023-02-23T17:09:28Z")

</div>

A Node-RED node that interacts with OpenAI machine learning models like "ChatGPT".

> **[node-red-contrib-custom-chatgpt](https://flows.nodered.org/node/node-red-contrib-custom-chatgpt)**
>
> ChatGPT in Node-RED

> **[GitHub - HaroldPetersInskipp/node-red-contrib-chatgpt: Node-RED ChatGPT](https://github.com/HaroldPetersInskipp/node-red-contrib-chatgpt)**
>
> Node-RED ChatGPT. Contribute to HaroldPetersInskipp/node-red-contrib-chatgpt development by creating an account on GitHub.

I encourage you to give it a try, any feedback or collaborators will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [23 February 2023 21:24 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644/2 "2023-02-23T21:24:39Z")

</div>

Here are some screenshots of the example flow and some output responses:

It can be used to generate completions, edits, and images.

 ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60f94a8373e7d142ed7d764126247d901298b3d3.jpeg)  
Here are some simple ways you can alter the behavior with a template node.  
 ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fbc38dfc321486fa3c7eb579f76f53c0973ba0b9.png)

---

<div class="post-metadata">

**Author:** ![wooferguy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wooferguy/32/75559_2.png) [@wooferguy](https://discourse.nodered.org/u/wooferguy)\
**Post date:** [2 March 2023 04:40 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644/3 "2023-03-02T04:40:42Z")

</div>

Kinda surprised this didnt get more attention - this is pretty big. If you can preload the node with the ability to output whatever format you want (like JSON?) then this could emulate just about any other collection of data transformation nodes.

I haven't had a play with it yet, does it have the ability to hold onto context in the same way that the OpenAI webpage implementation does?

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [2 March 2023 19:00 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644/4 "2023-03-02T19:00:13Z")

</div>

> [@wooferguy](#):
>
> Kinda surprised this didnt get more attention

@wooferguy,  
Yes indeed. I have the same feeling, but I can't give a decent explanation.

When developing (both for my daily job and for my Node-RED hobby), I use chatgpt very frequently because I gain a lot of knowledge by discussing with him/her/it.

And I am VERY convinced this will be a very useful node. But for some reason I lack some creativity to come up with a good use case to use in my flows. And most probably one day somebody will arrive here with a brilliant idea, and then I will go for it right away.

Just waiting for some good use cases from other people....

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [10 March 2023 22:48 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644/5 "2023-03-10T22:48:16Z")

</div>

The node has been updated to version 1.2.0 and now includes support for the `gpt-3.5-turbo` model and conversation history.

The included example has been updated as well.

 ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7ee99b6785bd0ed80568828cb4dd1f92abbe4b73.png)  
The full change log is available [here](https://github.com/HaroldPetersInskipp/node-red-contrib-chatgpt/blob/main/CHANGELOG.md)

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [10 March 2023 23:26 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644/6 "2023-03-10T23:26:22Z")

</div>

@wooferguy  
The recent update does allow it to hold onto context when using the new model `gpt-3.5-turbo `.  
To use the new model set `msg.topic` to `turbo` and you can then use the optional message property `msg.history` to input the conversation history. `msg.history` is expected to be an array of objects containing the conversation history.

`msg.history` should be formatted something like this:

```auto
[
    {
        "role": "user",
        "content": "Write a story about an Elephant."
    }, {
        "role": "assistant",
        "content": "An elephant is a gentle giant, with soft and wrinkled skin. It uses its long trunk to reach for food, and its broad ears to stay cool under the sun. It has two long tusks that can be used to defend itself, but its peaceful nature means it prefers to stay within its herd. Elephants are highly intelligent animals, with remarkable memories and complex communication skills. They are vital to their ecosystem, as their grazing habits help maintain the balance of the savannah. However, they are threatened by habitat loss and poaching for their ivory tusks. We must work to protect these magnificent animals and ensure their future survival."
    }, {
        "role": "user",
        "content": "Change it to be about a dog."
    }, {
        "role": "assistant",
        "content": "A dog is a loyal companion, with soft and furry fur. It uses its keen sense of smell to sniff out scents, and its sharp hearing to perceive sounds beyond human perception. It has sharp teeth that can be used to defend itself, but its friendly nature means it prefers to stick close to its owner. Dogs are highly adaptable animals, and their intelligence has made them a popular choice for a variety of tasks, ranging from service animals to police work. They bring joy and happiness to many, and their loving nature has made them a cherished member of families worldwide. However, they are susceptible to numerous health conditions and require proper care and nutrition to live a healthy, happy life. We must work to provide a loving home and appropriate care for our furry friends and appreciate the joy they bring into our lives."
    }
]

```

You should also be able to inject a pre-prompt behavior with the `msg.history` property like this:

```auto
[
    {
        "role": "system",
        "content": "You are a helpful assistant."
    }
]

```

Some more examples generated by chatgpt 😉

```auto
[{"role": "system", "content": "You are a helpful assistant that translates French to English."},
{"role": "user", "content": 'Translate the following French text to English: "{text}"'}]

[{"role": "system", "content": "You are a creative writing assistant, helping users generate new ideas and improve their writing."},
{"role": "user", "content": 'Please provide a writing prompt to help me generate some ideas.'}]

[{"role": "system", "content": "You are a technical support assistant, helping users troubleshoot and resolve issues with software or hardware."},
{"role": "user", "content": 'Please describe the problem you are experiencing and what steps you have already taken to try to resolve it.'}]

[{"role": "system", "content": "You are a news summarizer, providing concise summaries of current events."},
{"role": "user", "content": 'Please provide a news article for me to summarize.'}]

[{"role": "system", "content": "You are a poetry generator, helping users create unique and creative poems."},
{"role": "user", "content": 'Please provide a topic or theme for the poem you would like me to generate.'}]

[{"role": "system", "content": "You are a customer service representative, assisting customers with inquiries and resolving issues."},
{"role": "user", "content": 'What can I help you with today? Please describe your inquiry or issue.'}]

[{"role": "system", "content": "You are a language learning assistant, helping users learn a new language."},
{"role": "user", "content": 'Please provide a phrase or sentence for me to translate to the language you are learning.'}]

[{"role": "system", "content": "You are a personal finance advisor, providing advice and guidance on managing finances."},
{"role": "user", "content": 'Please provide details about your current financial situation and goals.'}]

[{"role": "system", "content": "You are an academic writing assistant, helping users improve their writing for academic purposes."},
{"role": "user", "content": 'Please provide a writing prompt or topic for me to help you generate ideas and improve your writing.'}]

[{"role": "system", "content": "You are a personality test administrator, helping users learn more about their personality traits."},
{"role": "user", "content": 'Please answer the following questions to learn more about your personality.'}]

```

However, in general, `gpt-3.5-turbo-0301` does not pay strong attention to the system message, and therefore important instructions are often better placed in a user message.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [10 March 2023 23:48 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-custom-chatgpt/75644/7 "2023-03-10T23:48:25Z")

</div>

I wonder if it could be used to write the help window contents for a node automatically in the correct format based off of a nodes JavaScript code. I don't feel that I know the Node-RED [Node help style guide](https://nodered.org/docs/creating-nodes/help-style-guide) well enough to create the prompt necessary for this yet.

Or similar prompts that could help facilitate creating nodes/subflows/etc.
