Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meeting error with JsonSerializationException when trying the ChatCompletion #99

Closed
jhinpan opened this issue Nov 30, 2023 · 6 comments
Closed

Comments

@jhinpan
Copy link

jhinpan commented Nov 30, 2023

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the sample
  2. Click on ChatGPT.cs
  3. Just try to normally make conversation with ChatGPT

Expected behavior
It reports error:
JsonSerializationException: Could not find member 'system_fingerprint' on object of type 'CreateChatCompletionResponse'. Path 'system_fingerprint', line 21, position 23.
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) (at <761cf2a144514d2291a678c334d49e9b>:0)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at <761cf2a144514d2291a678c334d49e9b>:0)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at <761cf2a144514d2291a678c334d49e9b>: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.String method, System.Byte[] payload) (at Library/PackageCache/com.srcnalt.openai-unity@1928201773/Runtime/OpenAIApi.cs:82)
OpenAI.OpenAIApi.CreateChatCompletion (OpenAI.CreateChatCompletionRequest request) (at Library/PackageCache/com.srcnalt.openai-unity@1928201773/Runtime/OpenAIApi.cs:259)
OpenAI.MicrophoneCapture.SendReplyToCopilot () (at Assets/Scripts/ChatGPT/MicrophoneCapture.cs:438)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) (at <88e4733ac7bc4ae1b496735e6b83bbd3>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0)
UnityEngine.UnitySynchronizationContext.Exec () (at :0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at :0)

Screenshots
0c4ab95b45147e92468ce5d4796ecc3

Environment (please complete the following information):

  • OS: Windows 10
  • Unity Version 2021.3.20f1
  • Plugin Version 0.1.15
@Edmonds39
Copy link

I met the same problem, but it didn't happen yesterday."

@alchemyharmony
Copy link

Same situation for me! I haven't managed to resolve it yet, but I found a helpful starting point at https://platform.openai.com/docs/guides/text-generation. The issue seems to be related to how the API is being invoked.

@TGM4939
Copy link

TGM4939 commented Nov 30, 2023

I managed to temporarily solve the issue. Not sure if its effecting anything internally, but when you double click the error, the line of code the error is being shown from, just remove this part ", jsonSerializerSettings".
So the adjusted line will be as follows:
data = JsonConvert.DeserializeObject(request.downloadHandler.text);

Again, I am not sure if this'll cause any other problems but it seems to be a temporary fix.

@Alan-Grech295
Copy link

I think the issue is that a system_fingerprint field is being sent in the response. I solved this by adding public int? System_fingerprint { get; set; } to the CreateChatCompletionResponse struct.

@omaratcygnus
Copy link

Came across this issue and found that there is a new variable added in response coming from GPT, that is "system_fingerprint". I just updated DataTypes.cs with updated string variable and it worked.

@jhinpan
Copy link
Author

jhinpan commented Nov 30, 2023

Thank you for your guys' help!!! Yeah, I think updating DataTypes.cs will temporarily solve this problem. Hope everyone does well through it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants