srcnalt/OpenAI-Unity

JsonSerializationException on CreateChatCompletion

Closed this issue · 2 comments

mifu67 commented

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:

  • OS: MacOS Ventura version 13.4
  • Unity Version [e.g. 2022.3.7f1]
  • Plugin Version [e.g. 0.1.5]

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

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

@srcnalt yes, that fixes the issue. Thanks!