Skip to content

Reconsider AIContent as an abstract class #6314

@stephentoub

Description

@stephentoub

If a provider has an object representing content for which there's no abstraction, they can use their own AIContent-derived type to represent it. If they don't want to have a public AIContent-derived type, they could just have it be internal, at least exposing the RawRepresentation and AdditionalProperties for the consumer to query. But if they do that, it won't work with Native AOT, as there'd then be no way for the consumer to build knowledge of that AIContent into a JsonSerializerOptions with source generation.

We should consider making AIContent non-abstract and giving it a public instead of protected constructor. Then such a scenario would work, and unknown AIContent could deserialize as the base type.

Metadata

Metadata

Assignees

Labels

area-aiMicrosoft.Extensions.AI libraries

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions