srcnalt / OpenAI-Unity

An unofficial OpenAI Unity Package that aims to help you use OpenAI API directly in Unity Game engine.
MIT License
672 stars 150 forks source link

Not working with WebGL builds #47

Closed LucienMaman closed 1 year ago

LucienMaman commented 1 year ago

Hi @srcnalt , thanks for this amazing project! As with previous similar issues, I am stuck with my WebGL build. It works well in the editor but not in the web version where I got an error 400 when posting to https://api.openai.com/v1/chat/completions (ie, when sending a message) from the game hosted on my website.

I am developing on MacOS (M1 chip) and the editor version is 2021.3.22f1. I tried to pull the latest code from the repo but still do not solve the issue.

Some of my build settings that might be of interest are attached. Any help would be really appreciated :)

I'll keep you updated if I find any solution in the meantime.

Cheers.

Capture d’écran 2023-04-25 à 13 06 19 Capture d’écran 2023-04-25 à 13 05 59
srcnalt commented 1 year ago

Hi @LucienMaman I was able to test on 3 different Unity versions and 2020.x and 2022.x worked, however 2021 is nor able to build it. Added a small table at the end of the readme file and I will update it as I can find more about which features break where.

LucienMaman commented 1 year ago

Hi @srcnalt, thanks for the support! However, I tried out to build it with the versions 2022.2.8f1 but also 2022.2.17f1, and I'm still receiving an error 400 when posting to https://api.openai.com/v1/chat/completions.

I double-checked, and it is working well in my editor. Any guess/hints I can try out to make it works? Thanks again,

srcnalt commented 1 year ago

I will be able to get my hands on a MAC only 2 weeks later, I hope some can with Mac can take a look and check that.

LucienMaman commented 1 year ago

Thanks @srcnalt. I will post an update if I manage to find the bug before you get access to a MAC :)

LucienMaman commented 1 year ago

Quick update, it looks like a similar issue as in #21

I tried the same debugging steps and it looks like the error comes from Newtonsoft as well. Not sure how to debug further yet.

LucienMaman commented 1 year ago

Hi @srcnalt, I had access to a PC so I tried to open my Unity project with it. The webGL build is still not working (ie, getting a 400 error when posting to chatGPT). It still works in the editor. I tried with the 3 versions as you did (2020, 2021, 2022), double-checked that the version of Newtonsoft was updated (ie, I tried with 3.1.0 and 3.2.0) and a similar issue is happening. Any help would be highly appreciated :)

Thanks!