srcnalt / OpenAI-Unity

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

JsonSerializationException on CreateChatCompletion #95

Closed mifu67 closed 7 months ago

mifu67 commented 7 months ago

Describe the bug Calling CreateChatCompletion results in a JsonSerializationException when attempting to deserialize the CreateChatCompletionResponse object. Full error: JsonSerializationException: Could not find member 'system_fingerprint' on object of type 'CreateChatCompletionResponse'. Path 'system_fingerprint', line 21, position 23.

To Reproduce Steps to reproduce the behavior:

  1. Call the following:

    var completionResponse = await openai.CreateChatCompletion(new CreateChatCompletionRequest() { Model = "gpt-4-1106-preview", Messages = [list of messages], Temperature = 0.0f, }

Expected behavior A populated completionResponse.

Environment:

Context: This was working yesterday. Maybe the OpenAI API updated?

srcnalt commented 7 months ago

Hi @mifu67 my guess also is that Open AI might have made system_fingerprint mandatory in the response type. Can you add public SystemFingerprint object { get; set; } in CreateChatCompletionResponse here to see if that fixes the issue?

I do not have an API Key, so I wont be able to test it unfortunately.

mifu67 commented 7 months ago

@srcnalt yes, that fixes the issue. Thanks!