Halftonex / npc-generator-gpt

Foundry VTT module - NPC generator for D&D5e powered by ChatGPT
Creative Commons Attribution 4.0 International
7 stars 10 forks source link

[BUG]: Request Denied even after inputing an API key #9

Closed Codedrummer closed 10 months ago

Codedrummer commented 10 months ago

Bug Description

I've followed the directions, installed the module, copied the API key and pasted it within the settings for the module, but I keep getting the request denied message

Steps To Reproduce

Install module Generate API key Paste API key in module settings Go to character tab Click create NPC Generate Screenshot 2023-11-13 182449

Foundry Version

Foundry 11.315

Additional Information

No response

Halftonex commented 10 months ago

send me the console log error screenshoot, here or on discord, whichever is more convenient for you.

edit. also it would be helpful to know which version of the module are you using

jcomplex commented 10 months ago

Seeing the same issue on Foundry v. 11.313 and module v. 1.5.4:

Access to fetch at 'https://api.openai.com/v1/chat/completions' from origin 'https://redacted' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

POST https://api.openai.com/v1/chat/completions net::ERR_FAILED 503 (Service Unavailable)

TypeError: Failed to fetch
    at npcGenGPTLib.callAI (lib.js:28:36)
    at npcGenGPTGenerateNPC.initGeneration (generateNPC.js:61:49)
    at HTMLButtonElement.dispatch (jquery.min.js:2:43184)
    at y.handle (jquery.min.js:2:41168)
Halftonex commented 10 months ago

Seeing the same issue on Foundry v. 11.313 and module v. 1.5.4:

@jcomplex, did the issue occur only once, or does it happen every time the module is used? are you on the forge?

Kaela696 commented 10 months ago

I am getting the same issue here is my error log. it is happening everytime I try to generate

NPC Generator (GPT) | Sending Request api.openai.com/v1/chat/completions:1 Failed to load resource: the server responded with a status of 500 () foundry.js:68326 NPC Generator (GPT) | Request Denied! Wait a few seconds and try again. (See console (F12) for more details) fetch @ foundry.js:68326 lib.js:40 Error: 500 | Message: Internal server error at npcGenGPTLib.callAI (lib.js:34:23) at async npcGenGPTGenerateNPC.initGeneration (generateNPC.js:61:30)

Halftonex commented 10 months ago

It's a OpenAI issue. The API status page reports:

Elevated Errors on API and ChatGPT Identified - The issue has been identified and a fix is being implemented. Investigating - We're experiencing an elevated level of API errors and are currently looking into the issue.

https://status.openai.com/

chrisnciss commented 10 months ago

I'm not sure their reported issue is what's causing these denies. May be another that they're unaware of, but I'm still experiencing the issue and they reported a fix on 11/23.

Halftonex commented 10 months ago

hey @chrisnciss, can you please send me a screenshot of the console error regarding the issue that you're experiencing?

Ruinwolf commented 10 months ago

image image I am having this same issue, it seems to be code 429 error is what I think I need to resolve, (See Screen Shot)

Ruinwolf commented 10 months ago

I'm no expert, so I'm just spamming my thoughts.

Halftonex commented 10 months ago

@Ruinwolf as you can see from the error it reports that you have no credit on your openAI account, that's why it refuses your call. Note, as I mention in the readme file, that OpenAI APIs are not free to use although they are really cheap.

I'm gonna edit the readme so this will be more clear since many people are not aware of it, my bad taking it for granted and apologies for the inconvenience.