FlowFuse / node-red-function-gpt

A Node-RED node that adds "Ask ChatGPT" option to a duplicate of the built-in function node.
Apache License 2.0
29 stars 2 forks source link

common.notification.error #16

Closed battosai30 closed 1 year ago

battosai30 commented 1 year ago

Current Behavior

I've just installed this node on my own NodeRed instance, not FlowForge (maybe it's the problem ?)

API key + OrgID configured (Keys used in other services so sure they're valid) Model = code-davinci-002 or gpt-3.5-turbo

Click on "Ask ChatGPT" immediatly leads to a popup "common.notification.error"

image

Expected Behavior

No response

Steps To Reproduce

No response

Environment

joepavitt commented 1 year ago

Thanks for raising the issue. It should definitelt work outside of FlowForge, we didn't want to gate keep!

Could I check, upon adding the node to the canvas, did you deploy first, before asking ChatGPT a question?

We have an issue at the moment where you need to deploy, once the node is added, but before tou written any code in the function node - see #13

I would expect it to show a much nicer error than this though!

oywino commented 1 year ago

I'm not using FlowForge, and I have the same issue.

joepavitt commented 1 year ago

Thanks for letting us know @oywino - are you using same Operating System and Browser combo as reported too?

Have you tried the steps I'd mentioned above?

oywino commented 1 year ago

Thanks for letting us know @oywino - are you using same Operating System and Browser combo as reported too?

Have you tried the steps I'd mentioned above?

NodeRed: 3.0.2 Docker container Chrome on Win 10

I have tried all the steps recommended.

Rgds Oywin

joepavitt commented 1 year ago

@Steve-Mcl can you think of anything we added that would have been Node-RED 3.1 specific? I know we used 3.1 when dev'ing. I can't think of anything obvious myself?

Will try this out for myself once I'm back at my desk on Tuesday.

Thanks both for the details.

Steve-Mcl commented 1 year ago

No, can't think of anything specific to either FlowForge or 3.1-beta.

oywino commented 1 year ago

What does the error message common.notification.error actually mean in this context?

Rgds Oywin

joepavitt commented 1 year ago

It means that Steve and I forgot to put a proper error message in and that Node-RED is resorting to a default placeholder 😬

joepavitt commented 1 year ago

Do you see any errors reported in the Node-RED terminal/cmd line logs?

The error will be coming from: https://github.com/flowforge/node-red-function-gpt/blob/main/index.html#L635

Which means our API endpoint is returning at error other than 404 (Not Found) or 500 (Internal Server Error)

That's odd though, because our API is only configured to return 1 of those 2 error states when it fails:

https://github.com/flowforge/node-red-function-gpt/blob/main/index.js#L504

Hopefully something is being logged that helps us here. I'm doing this all from phone btw, will be at my laptop on Tuesday when I can investigate properly

oywino commented 1 year ago

I'm not sure where to find that/those logs. Please direct me.

joepavitt commented 1 year ago

When you run Node-RED from the command line, or within the Docker container, you should see the logs printed there as it starts up. Wherever you run the node-red command from.

The docs for the Docker Container do mention that a terminal/command line window gets opened, where you see the "Started Flows...", etc.

That's where any errors should be getting logged to

battosai30 commented 1 year ago
manglemender commented 1 year ago

I seem to have the same issue. OS: Rasbian64 bit NR: V3.0.1 (runs as a service) Browser: Chrome on Win10

I noted the error below on startup. Not sure if it's related.

9 May 15:41:34 - [warn] [function-gpt] Registered invalid property name 'functionExternalModules'. Properties for this node must start with 'functionGpt'

I did deploy the flow before attemting to use the ask GPT function

Nick

Update: I just tried it under win10 with NR3.0.2 and using edge as a browser and it worked fine. more research needed Update: tested the chrome browser and works OK Update: No error was reported to the console on the Pi - See picture image

joepavitt commented 1 year ago

Thanks @manglemender - just to check you mentioned you tested the chrome browser and works OK but the original browser you mentioned that you used was Chrome on Win10 - what changed?

joepavitt commented 1 year ago
Screenshot 2023-05-09 at 17 06 05

So the error is being triggered by the RED.auth.needsPermission middleware here, which is returning a 401. @Steve-Mcl we set it as:

RED.auth.needsPermission("function-gpt.write")

which on review back, doesn't look right, where would this value be set? Not sure why this would be working locally either, as I don't recall setting this ourselves?

This is venturing outside of my own Node-RED dev knowledge

manglemender commented 1 year ago

Thanks @manglemender - just to check you mentioned you tested the chrome browser and works OK but the original browser you mentioned that you used was Chrome on Win10 - what changed?

@joepavitt Sorry if that wasn't clear through my updates. What I discovered was that the issue was not browser related. The node worked OK with NR running on a windows platform regardless of browser but it did not work with NR running on Raspbian OS (64)

Nick

Paul-Reed commented 1 year ago

I get both errors mentioned above; After installing the node via 'Manage Palette', I see this this in the debug panel...

gpt_error

..and trying to use the node, I see this;

common_not

I did deploy the node first. Same result after restarting Node-RED. No errors in NR log In the browser console I get;

brows

(I'm not good at interpreting the error) but I believe that leads me to;

                    o = o("abort");
                    try {
                        r.send(i.hasContent && i.data || null)
                    } catch (e) {
                        if (o)
                            throw e
                    }
                },
                abort: function() {
                    o && o()
                }

OS - Canonical-Ubuntu-22.04-aarch64-2023.02.15-0 Oracle cloud VM server Node-RED v3.0.2 node v18.15.0

Steve-Mcl commented 1 year ago

Fyi, I have resolved this locally and will publish an update tomorrow.

oywino commented 1 year ago

Great! Can't wait to hear about it 🤗

oywino commented 1 year ago

Fyi, I have resolved this locally and will publish an update tomorrow.

Nothing came..... 😪

Steve-Mcl commented 1 year ago

Fyi, I have resolved this locally and will publish an update tomorrow.

Nothing came..... 😪

I've had a busy day :)

however, if you look again...

oywino commented 1 year ago

I've had a busy day :) however, if you look again...

Look where?

joepavitt commented 1 year ago

@oywino Steve has opened a PR. I'll review today hopefully and if all is working, have it released later

joepavitt commented 1 year ago

We have just published v0.2.1 to the Node-RED library with a fix in for this, in addition to more verbose error logging. This may take half an hour or so to refresh in the "Palette" of Node-RED.

battosai30 commented 1 year ago

Upgraded aaaannnnnnddddddd ...... it works :)

Thank you !