srcnalt / OpenAI-Unity

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

JsonSerializationException: No JSON content found and type 'OpenAI.CreateAudioResponse' is not nullable. Path '', line 0, position 0. #119

Open Exiro001 opened 8 months ago

Exiro001 commented 8 months ago

JsonSerializationException: No JSON content found and type 'OpenAI.CreateAudioResponse' is not nullable. Path '', line 0, position 0. Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) (at <761cf2a144514d2291a678c334d49e9b>:0) Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at <761cf2a144514d2291a678c334d49e9b>:0) Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at <761cf2a144514d2291a678c334d49e9b>:0) Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) (at <761cf2a144514d2291a678c334d49e9b>:0) Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) (at <761cf2a144514d2291a678c334d49e9b>:0) OpenAI.OpenAIApi.DispatchRequest[T] (System.String path, System.Collections.Generic.List`1[T] form) (at C:/Users/LENOVO ONE/Downloads/OpenAI-Unity-0.2.0/OpenAI-Unity-0.2.0/Runtime/OpenAIApi.cs:176) OpenAI.OpenAIApi.CreateAudioTranscription (OpenAI.CreateAudioTranscriptionsRequest request) (at C:/Users/LENOVO ONE/Downloads/OpenAI-Unity-0.2.0/OpenAI-Unity-0.2.0/Runtime/OpenAIApi.cs:336) Samples.Whisper.Whisper.EndRecording () (at Assets/Samples/OpenAI Unity/0.2.0/Whisper/Whisper.cs:73) System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) (at <27124aa0e30a41659b903b822b959bc7>:0) UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0) UnityEngine.UnitySynchronizationContext.Exec () (at :0) UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at :0)

this all occurred in all samples provided

srcnalt commented 8 months ago

Hi @Exiro001, the received response is not a JSON, so it might me a message about quota limit or something else. You can print out the response before it gets parsed and see what the error says.

markaeron-ns commented 7 months ago

I've encountered the same error but I haven't reached my quota limit. I just bought 5$ worth of tokens / quota. The error I see in VR is:

JsonSerializationException: No JSON Content found and type 'OpenAI.CreateAudioResponse' is not nullable. Path '', line 0, position 0

It works in the editor but doesn't work in VR. Since the API key is being read from auth.json, I manually placed the API key inside the script instead inside the = new OpenAI("apikey", "orgkey");. To my surprise, I still receive the same error.

JensDijkgraaf commented 7 months ago

I have had the same issue, after adding the API/Organization key had the same issue still, what solved it for me is going to: build settings -> player settings -> publishing settings, then enable Custom Main Manifest. Go to the manifest file and add the following line:

within the manifest class. Hope this helps!

tobivr commented 7 months ago

@JensDijkgraaf we have the same issue... what is the line you have added to the manifest? Its not visible in your post 😄 In our case its working on the Editor as well but on iOS we are seeing the issue from above.

JensDijkgraaf commented 7 months ago

@tobivr my bad, the line you need to add is:

<uses-permission android:name="android.permission.INTERNET" />

as can be seen in the line this is specifically for android, but i can imagine there would be a similar but slightly different solution for iOS, hope it helps!

hridayc7 commented 5 months ago

I added in what you said @JensDijkgraaf, however, I am still receiving the same issue. Any other ideas perhaps? EDIT/UPDATE: After having issues, I realized I needed to do something similar to what was done here https://github.com/srcnalt/OpenAI-Unity/issues/117 --> with the XR settings and force internet permissions. Thank you all for your help!