hexthedev/OpenAi-Api-Unity

ERROR: status code: Unsupported Media Type

Closed this issue · 7 comments

Hi,

First, thank you for this great library!

I followed all the instructions, setup, API key, etc. After loading the Example Runtime scene, I get this error:

image

Any idea what could be the problem ?

Small update, I secured some more tokens so i'll be updating this library end of the month!

I can’t look into this soon as I have a few other deadlines to hit, but if you want to look yourself you need to go to OpenAi-Api-Unity/Runtime/Scripts/Api/V1/Models. Here you will find all classes used to serialize the arguments for completion functions. If you cross reference this with: API Reference - OpenAI APIhttps://beta.openai.com/docs/api-reference/introduction for the things you want to do you might be able to do a custom quick fix.

Great I'll look into it if I have the time!

Ok, after some debugging, I found out that the problem came from the serialization of the data sent to the server. The float temparature in specific. For some reason, when converted to string, a coma is added which invalidate the JSON format.

image

That's why it's not happening on my side. Comma's being used in float parsing/serialization comes from language preferences. Using a comma instead of a point is the French way of doing decimal notation. C# actually pulls language optinos from your computer to make this decision.

I will fix this in a release next week, but in the mean time here is what you can try.

In JsonBuilder.cs, replace

image

with

image

Make sure to add

image

Good catch, this one didn't come up in testing. Hope this helps

Great! Thanks for the quick fix!