Closed
Description
Library name
System.ClientModel
Please describe the feature.
BinaryContent is used all protocol method scenarios. A typical usage today looks like the following
BinaryContent content = BinaryContent.Create(BinaryData.FromObjectAsJson(
new {
model = "gpt-4.1",
prompt = new {
id = "pmpt_abc123",
version = "2",
variables = new {
customer_name = "Jane Doe",
product = "40oz juice box"
}
}
}
It would be nice to simplify it to:
BinaryContent content = BinaryContent.CreateJson(
new {
model = "gpt-4.1",
prompt = new {
id = "pmpt_abc123",
version = "2",
variables = new {
customer_name = "Jane Doe",
product = "40oz juice box"
}
}
}
Similarly with other scenarios that consume BinaryData. And so we should the following members to BinaryContent
public string? MediaType { get; }
public static BinaryContent CreateJson<T>(T jsonSerializable, System.Text.Json.JsonSerializerOptions? options = default);System.Text.Json.Serialization.Metadata.JsonTypeInfo<T> jsonTypeInfo
public static BinaryContent CreateJson<T>(T jsonSerializable, System.Text.Json.Serialization.Metadata.JsonTypeInfo<T> jsonTypeInfo);