[ANNOUNCE] OpenAi Node-RED Plugin

Hi everyone, Im pleased to introduce my open-source OpenAI plugin. Build Flows, generate explainers, and create specifications within Node-RED!

This is an early release, I have lots planned, and will publish a roadmap, github and issues soon, for now you can load the plugin via npm.

https://www.npmjs.com/package/@thingcode/node-red-plugin-openai

To deploy this project run in your Node-RED folder.

npm i @thingcode/node-red-plugin-openai

Append to your package.json

"node-red": {
        "plugins": {
            "openai": "plugin.js"
        }
    }

Once the plugin is loaded, you'll have a new tab in the Sidebar called OpenAi.

Click the gear icon to add your OpenAi API Token (Note, currently this is stored unencrypted in .config.runtime.json)

You'll now see two new panels, one called Build and one called Explainers.

Using Build you can describe a flow, function, configured switch node etc. e.g.

a function node, to make a string lowercase connected to an inject and debug node
a switch node, with outputs for payload Foo, Bar, Baz
5 mqtt nodes with topics, mqtt/foo1, mqtt/foo2 etc

Click build, the plugin will then generate the Nodes needed and will after a short wait make them available for you to place in a flow, on the same way as Import Flows.

Using Explainers you can generate text explainers and specifications within the editor. Choose a single Flow, All Flows or a Selected Node, click the explainer, a side panel will open and the text will be streamed to a tab. You can stop, reload, close and open the explainer tab as needed.

Notes.
Beta release, backup your flows before using.

Your flow file is sent to the OpenAi API's.

Your OpenAi API Token is currently stored unencrypted in .config.runtime.json

Sometimes the response from OpenAi will be broken, currently implementing function calling to reduce this. Usually a retry or small change to your prompt will improve the response.

Project will be open-source on GitHub soon.

Get creative, excited to talk more!

Max

3 Likes

I'd love to know about people's experiences with usage charges when using this.

One of the things that puts me off using the API is uncertainty about how much it costs.

Well that and OpenAI's poor track record on privacy and security but that's for a different conversation perhaps.

2 Likes

Thank you A good point about charges and cost, I should have mentioned at least which endpoint is being used, here's some details -

The plugin currently uses the OpenAi GPT-3.5 Turbo endpoint.

The pricing information can be found at https://openai.com/pricing You can set a spending limit within your OpenAi account page, as well there is a Usage Page that shows you your spend, it seems to update pretty quickly, after requests.

When using the Build tab within the plugin, with the Import option set (the default) the number of tokens used is generally very low. The text you type is sent as a prompt, and only the JSON defining your Node/Nodes is received as a response.

When using the explainer tab within the plugin, your flow.json file is sent as the prompt along with a system prompt, the size of the flow file, will define the cost however this is still generally pretty low.

I'm also super interested to hear from others on this topic.

Ultimately I see this plugin using a self hosted, open source model which I'm also working on (llama 2). To fill the gap OpenAi will continue to be used.

If people are interested I may host an endpoint for a fixed cost per month, with a fair usage limit?

Please remember this is an early Beta, the above is my experience using it, but not guaranteed, best monitor the usage and set a spending cap to be sure. In the future I'll include in the plugin some indicator of tokens used, to help understand the costs.

Hi Max, I'm a AI newbie, and wondered what's the advantage in using this compared with using the browser based ChatGPT?
Is there any benefit :thinking:

@MaxBaines,
Thanks for sharing this plugin!
The link to your Github repo (via your npm page) is not valid. I see that you have no public repositories. Is it the intention to keep this plugin in a private repository?
Bart

2 Likes

Thought a video would be useful, here's a YouTube link.

https://www.youtube.com/watch?v=Q0ejnWJElgo

3 Likes

Hi Paul, I think most of us are newbie's when it comes to the use of ai and GPT. Actually it was using ChatGPT and copy, pasting Node-RED flow json via Import that inspired me to make the plugin.

Take a look at the YouTube video I posted below. You'll see things are not perfect, sometime's the response is wrong, or just broken. But when using it I have found it to be useful for creating configured nodes, things like a switch node with 5 outputs, split by a topic, or to create a function, to parse or split a string etc. And explainers have been great to kick off documentation, flow specs etc.

Super interested to hear from everyone whether there is a benefit?

Hi Bart,

Pleased to finally work on a Node-RED plugin I can share with everyone!

The repository will be public soon I hope this week, or next and I look forward to working on it hopefully with others, as an open source project.

Why not yet? the current repo includes all the dev from day dot, it could include flows form other projects, keys etc, I need to clean that up before being public, plus licence, readme, issues etc.

Thanks, Max.

2 Likes

Be careful with clearing your commit history. It might be easier to delete the repo and re-create it to be sure that there is nothing sensitive in the history. I am sure you already know that, but just in case you didn't.

2 Likes

Looking at the video, I can see that it actually creates the flow in your workspace, which is pretty neat :+1:

Nice work Max

3 Likes

Yes, nice work!! Thanks for the video!

1 Like

This is something i was wondering was possible, great implementation, cheers!

1 Like

Another item not mentioned yet by me, which may be of some concern or interest is privacy of your data. There is often some confusion in most communities and indeed professions at the minute about how OpenAi treat you data, I needed to look into this as part of my job, hopefully the following helps -

The plugin, sends and receives responses from the OpenAI API. When using the OpenAI API's your data is not retained or used to train models, for details see:

Note, this is a different policy to ChatGPT itself, when using ChatGPT your data is retained and used to train models.

To be clear this plugin does not use ChatGPT instead it uses the OpenAI API.

2 Likes

I look forward to trying this. As a lousy coder (it's not my day job), I've found ChatGPT incredibly helpful for all kinds of purposes.

One question: now that GPT4 API keys have become more available, will you support that API endpoint? GPT4 really is a significant leap over 3.5...

Hi Nick, really interested to hear your thoughts once you've tried it. I hope as this project matures, it'll help people who's day job is not coding, for those of us where it is, speaking for myself its improved my productivity building flows, by saving time on config of nodes etc.

I was lucky to have access to GPT4 really early, I agree it's great leap and when using with this plugin it's correct on every request. The GPT4 API calls are in the code and there will be a drop down in the config soon, maybe this weekend.

I removed it as the default as the cost of GPT4 is significantly higher than 3.5 (Pricing) during dev in a day I spent about Ā£10 on GPT4 where as using 3.5 its pennies. So I want to pursue 3.5 as the default for now. Although as GPT4 has a larger context window, we can do some impressive things with large flow files, like name all the nodes, refactor flows etc.

Thanks.

Max

2 Likes