You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Custom additional properties is ignored when mapping to OpenAI.Chat.ChatCompletionOptions models.
The static method ToOpenAIOptions in OpenAIModelMapper.ChatCompletion.cs leaves custom properties unhandled.
It works fine in OpenAI .NET library using IJsonModel and JsonElement for serialization.
Reproduction Steps
// passing "web_search" for some LLMs...varoptionJson=""" { "model": "some LLM model id", "stream": true, "web_search": { "enabled": true, "enable_trace": true, "enable_citation": false }, "stream_options": { "include_usage": true }, "messages": [ { "role": "user", "content": "some user prompts...." } ] }"""u8.ToArray();///////////// case OpenAI serialization senario:ChatCompletionOptionsopenAIChatCompletionOptions=new();varbinaryData=BinaryData.FromBytes(optionJson);openAIChatCompletionOptions=((IJsonModel<ChatCompletionOptions>)openAIChatCompletionOptions).Create(binaryData,ModelReaderWriterOptions.Json);// We can find additional serialized data successfully deserialized///////////// case MEAI serialization senario:usingMemoryStreamoptionStream=new(optionJson);varchatRequest=awaitOpenAISerializationHelpers.DeserializeChatCompletionRequestAsync(optionStream);varoptions=chatRequest.Options;// Properties missing after deserialization.
Expected behavior
Custom properties will also be deserialzed.
Actual behavior
Custom properties unhandled.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered:
arthuridea
changed the title
[MEAI] Custom ChatOptions.AdditionalProperty ignored on deserialization.
[MEAI] Custom ChatOptions.AdditionalProperties ignored on deserialization.
Mar 23, 2025
This support is being removed as part of #6094 / #6138. It's relying on private reflection into the OpenAI library and is not something we can actually make stable. The missing properties here are a good example of how it's deficient, since the OpenAI library it wraps doesn't expose the ability to achieve this.
This support is being removed as part of #6094 / #6138. It's relying on private reflection into the OpenAI library and is not something we can actually make stable. The missing properties here are a good example of how it's deficient, since the OpenAI library it wraps doesn't expose the ability to achieve this.
Will the whole ChatClient(or other clients) implementation or only mapping extension methods be removed?
Should I open an issue in OpenAI.NET repo,rquesting if any public methods will be provided, or in some day,we can use a rquest & response mapping delegations here?............which will make codes ugly :( @stephentoub
Description
Custom additional properties is ignored when mapping to OpenAI.Chat.ChatCompletionOptions models.
The static method
ToOpenAIOptions
inOpenAIModelMapper.ChatCompletion.cs
leaves custom properties unhandled.It works fine in OpenAI .NET library using IJsonModel and JsonElement for serialization.
Reproduction Steps
Expected behavior
Custom properties will also be deserialzed.
Actual behavior
Custom properties unhandled.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: