Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive support for interacting with AI service-hosted files through a new IHostedFileClient interface and related abstractions. The feature enables uploading, downloading, and managing files used by AI services, particularly for code interpreter operations.
Changes:
- Introduces
IHostedFileClientinterface with upload, download, get, list, and delete operations - Adds supporting types:
HostedFile,HostedFileDownloadStream, and various options classes - Implements OpenAI provider integration with support for both standard Files API and container-scoped files
- Includes
DelegatingHostedFileClientbase class for middleware patterns - Adds
HostedFileClientBuilderfor creating file client pipelines - Implements logging and OpenTelemetry middleware for observability
- Provides comprehensive extension methods for common operations
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/DiagnosticIds/DiagnosticIds.cs | Adds AIFiles experimental diagnostic ID |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/IHostedFileClient.cs | Core interface defining file operations |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/HostedFile.cs | Metadata model for hosted files |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/HostedFileDownloadStream.cs | Abstract stream base for file downloads |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/HostedFileClientOptions.cs | Base options class with Scope and AdditionalProperties |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/HostedFile*Options.cs | Specific option classes for each operation |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/HostedFileClientMetadata.cs | Provider metadata model |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/DelegatingHostedFileClient.cs | Base class for middleware implementations |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Files/HostedFileClientExtensions.cs | Extension methods for common file operations |
| src/Libraries/Microsoft.Extensions.AI/Files/HostedFileClientBuilder.cs | Builder for creating file client pipelines |
| src/Libraries/Microsoft.Extensions.AI/Files/HostedFileClientBuilderHostedFileClientExtensions.cs | AsBuilder extension method |
| src/Libraries/Microsoft.Extensions.AI/Files/LoggingHostedFileClient.cs | Logging middleware implementation |
| src/Libraries/Microsoft.Extensions.AI/Files/LoggingHostedFileClientBuilderExtensions.cs | UseLogging extension |
| src/Libraries/Microsoft.Extensions.AI/Files/OpenTelemetryHostedFileClient.cs | OpenTelemetry tracing/metrics middleware |
| src/Libraries/Microsoft.Extensions.AI/Files/OpenTelemetryHostedFileClientBuilderExtensions.cs | UseOpenTelemetry extension |
| src/Libraries/Microsoft.Extensions.AI/OpenTelemetryConsts.cs | Adds File.Name and File.Size constants |
| src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIHostedFileClient.cs | OpenAI implementation with Files and Container API support |
| src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIFileDownloadStream.cs | Download stream wrapper for OpenAI responses |
| src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs | AsIHostedFileClient extension methods |
| src/Libraries/Microsoft.Extensions.AI/Microsoft.Extensions.AI.csproj | Enables MediaTypeMap injection |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Defaults.cs | Adds JSON serialization support |
| test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/TestHostedFileClient.cs | Test helper implementation |
| test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Files/*.cs | Unit tests for abstractions |
| test/Libraries/Microsoft.Extensions.AI.Tests/Files/*.cs | Unit tests for middleware |
| test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/*.cs | Unit and integration tests for OpenAI implementation |
| test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj | Links TestHostedFileClient |
Adds an abstraction for interacting with files AI services host, for things like input and output of code interpreter.
- Missing GetRequiredService methods - Disposing of caller's Stream in OpenAI upload
0cf7b85 to
5bfc6fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an abstraction for interacting with files AI services host, for things like input and output of code interpreter.
Microsoft Reviewers: Open in CodeFlow