briansunter / logseq-plugin-gpt3-openai

A plugin for GPT-3 AI assisted note taking in Logseq
https://twitter.com/bsunter
MIT License
716 stars 75 forks source link

Refused to set unsafe header "User Agent" #27

Open phreshsprout opened 2 years ago

phreshsprout commented 2 years ago

Hi, your get-youtube-captions plug-in has been a great help in getting youtube transcripts into Logseq, thanks so much!

Now attempting to use the gp3 plug-in but can't seem to get it working. First was getting a 429 error, so I upgraded to a subscription with openai.. Any insight for a path forward would be appreciated.

Error-Logseq-OpenAI-plugin-Screenshot 2022-09-26 092551

briansunter commented 2 years ago

Hey! a 400 error means the api key might be in there incorrectly. Try double checking the API key and restarting logseq

A 429 error means rate limiting, which is an error from openai when you call them to frequently. I'll work on better handling of this error.

In the meantime, double check the API key to fix the 400s, and if you see 429s, wait a couple minutes and try again.

cldwalker commented 2 years ago

Hi. I'm also seeing the error Refused to set unsafe header "User-Agent" after not using the plugin for a bit. Just to be sure, I created a new API key and still the got the same 429 from openai. All the plugin configuration settings have default values e.g. text-davinci-002. Perhaps this is related to https://github.com/openai/openai-node/issues/6 ? Thanks for the great plugin

briansunter commented 2 years ago

Hmm, I also see the unsafe header error in my console, but I get a 200 success.

Could you take a look at what the response message is for the 429 errors? Does it happen every time and consistently? Or every once in a while?

Based on looking at the openai forums, it sounds like they occasionally throw these errors for low traffic levels.

https://community.openai.com/t/server-always-results-in-429-errors-with-fine-tuned-models/21290

If you're only seeing this occasionally, I could add some retry/buffering to make the error show up to users less often. I think I may need to handle and expect this error, even for infrequent calls.

cliffordx commented 2 years ago

Error persist.

Screen Shot 2022-10-14 at 12 25 39 AM
briansunter commented 2 years ago

@cliffordx would you be able to check the error message in the networking tab?

And is it happening on every request or only occasionally?

briansunter commented 2 years ago

I have a fix for this here that I'm currently testing. It should help alleviate the 429 errors.

The unsafe user agent message in the logs doesn't cause any issues, so ignore it for now. I'm working on a PR to the openai SDK to fix the user agent message. I updated the readme to reflect it.

If you know how to load unpacked plugins, would be great if you could help test this build!

https://github.com/briansunter/logseq-plugin-gpt3-openai/pull/29

cldwalker commented 2 years ago

My 429 response contains:

{
    "error": {
        "message": "You exceeded your current quota, please check your plan and billing details.",
        "type": "insufficient_quota",
        "param": null,
        "code": null
    }
}

I looked around in the dashboard and it wasn't obvious that my quota was exceeded. Looking at https://beta.openai.com/account/api-keys doesn't indicate anything. On https://beta.openai.com/account/usage, I was able to see that my 3 month trial had ended, not that I had exceeded a quota. Perhaps this issue could just be resolved with some messaging guiding people to check if their trial has expired in addition to checking their quota

cliffordx commented 2 years ago

My 429 response contains:

{
    "error": {
        "message": "You exceeded your current quota, please check your plan and billing details.",
        "type": "insufficient_quota",
        "param": null,
        "code": null
    }
}

I looked around in the dashboard and it wasn't obvious that my quota was exceeded. Looking at https://beta.openai.com/account/api-keys doesn't indicate anything. On https://beta.openai.com/account/usage, I was able to see that my 3 month trial had ended, not that I had exceeded a quota. Perhaps this issue could just be resolved with some messaging guiding people to check if their trial has expired in addition to checking their quota

I can confirmed this response is similar to mine but haven't used GPT for a while.

briansunter commented 2 years ago

Great. Thanks for the response payload. I’m working on a change to surface those errors better. #30

cldwalker commented 2 years ago

New error is helpful. Thanks!