Skip to content

How can we represent AIContent that's not entirely in memory? #6683

@ericstj

Description

@ericstj

DataContent can only be backed with a ReadOnlyMemory, we should also have type that can be backed with a stream so that we don't have to store large content in memory.

Ideally this type could support a stream without ever loading the entire contents to the stream (eg: as an internal Uri representation, or string representation, or fully buffered)

We should decide if such a representation would require a seeable stream, or if it could be made "one shot" where we wrap a non-seekable stream that would only ever be consumed once - either by copying out to another stream, or converting to some other AIContent like as a DataContent, or maybe a seekable version.

This seems similar to https://learn.microsoft.com/en-us/dotnet/api/system.net.http.streamcontent?view=net-8.0 vs https://learn.microsoft.com/en-us/dotnet/api/system.net.http.bytearraycontent?view=net-8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-aiMicrosoft.Extensions.AI librariesuntriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions