-
Notifications
You must be signed in to change notification settings - Fork 829
Closed as not planned
Closed as not planned
Copy link
Labels
area-aiMicrosoft.Extensions.AI librariesMicrosoft.Extensions.AI librariesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.
Description
Description
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...
var optionJson = """
{
"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:
ChatCompletionOptions openAIChatCompletionOptions = new();
var binaryData = BinaryData.FromBytes(optionJson);
openAIChatCompletionOptions = ((IJsonModel<ChatCompletionOptions>)openAIChatCompletionOptions).Create(binaryData, ModelReaderWriterOptions.Json);
// We can find additional serialized data successfully deserialized
///////////// case MEAI serialization senario:
using MemoryStream optionStream = new(optionJson);
var chatRequest = await OpenAISerializationHelpers.DeserializeChatCompletionRequestAsync(optionStream);
var options = 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
Metadata
Metadata
Assignees
Labels
area-aiMicrosoft.Extensions.AI librariesMicrosoft.Extensions.AI librariesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.