[BUG] Cannot convert from json (or deserialie) ChatRequestUserMessage object with MultimodalContentItems #42503
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
needs-team-attention
This issue needs attention from Azure service team or SDK team
OpenAI
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
This issue is responsible by Azure service team.
Library name and version
Azure.AI.OpenAI 1.0.0-beta.14
Describe the bug
ModelReaderWriter.Read(string) method throw the Exception. The string parameter is generated by ModelReaderWriter.Write(ChatCompletionsOptions) method, and the ChatCompletionsOptions has user message which has multi modal content.
Exception:
System.InvalidOperationException: The requested operation requires an element of type 'String', but the target element has type 'Array'.
at System.Text.Json.ThrowHelper.ThrowJsonElementWrongTypeException(JsonTokenType expectedType, JsonTokenType actualType)
at System.Text.Json.JsonDocument.GetString(Int32 index, JsonTokenType expectedType)
at Azure.AI.OpenAI.ChatRequestUserMessage.DeserializeChatRequestUserMessage(JsonElement element, ModelReaderWriterOptions options)
at Azure.AI.OpenAI.ChatRequestMessage.DeserializeChatRequestMessage(JsonElement element, ModelReaderWriterOptions options)
at Azure.AI.OpenAI.ChatCompletionsOptions.DeserializeChatCompletionsOptions(JsonElement element, ModelReaderWriterOptions options)
at Azure.AI.OpenAI.ChatCompletionsOptions.System.ClientModel.Primitives.IPersistableModel<Azure.AI.OpenAI.ChatCompletionsOptions>.Create(BinaryData data, ModelReaderWriterOptions options)
at System.ClientModel.Primitives.ModelReaderWriter.Read[T](BinaryData data, ModelReaderWriterOptions options)
at MyAoaiPlayground.BlazorServer1.Components.Pages.SendCompletion.SaveHistory() in C:\Users\ainaba\source\repos\my-aoai-playground\src\MyAoaiPlayground.BlazorServer1\Components\Pages\SendCompletion.razor:line 162
Expected behavior
I want to serialize and deserialize ChatCompletionOptions object with all parameters and messages to persistent history.
Actual behavior
ChatRequestUserMessage instance cannot deserialize from json which user role message content property as Array, which generated by MultiModalContentItems. This case occurs when using GPT4 with Vision, and ChatRequestUserMessage is constructed by IEnumerable parameter.
If content property is single String type, which generated by a constructor with single string, it can be deserialized.
Reproduction Steps
The text was updated successfully, but these errors were encountered: