4 implementations of IHostedFileClient
Microsoft.Extensions.AI.Abstractions (1)
Files\DelegatingHostedFileClient.cs (1)
23public class DelegatingHostedFileClient : IHostedFileClient
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestHostedFileClient.cs (1)
14internal sealed class TestHostedFileClient : IHostedFileClient
Microsoft.Extensions.AI.OpenAI (1)
OpenAIHostedFileClient.cs (1)
44internal sealed class OpenAIHostedFileClient : IHostedFileClient
Microsoft.Extensions.AI.Tests (1)
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestHostedFileClient.cs (1)
14internal sealed class TestHostedFileClient : IHostedFileClient
176 references to IHostedFileClient
Microsoft.Extensions.AI (25)
Files\HostedFileClientBuilder.cs (18)
12/// <summary>A builder for creating pipelines of <see cref="IHostedFileClient"/>.</summary> 16private readonly Func<IServiceProvider, IHostedFileClient> _innerClientFactory; 19private List<Func<IHostedFileClient, IServiceProvider, IHostedFileClient>>? _clientFactories; 22/// <param name="innerClient">The inner <see cref="IHostedFileClient"/> that represents the underlying backend.</param> 24public HostedFileClientBuilder(IHostedFileClient innerClient) 31/// <param name="innerClientFactory">A callback that produces the inner <see cref="IHostedFileClient"/> that represents the underlying backend.</param> 33public HostedFileClientBuilder(Func<IServiceProvider, IHostedFileClient> innerClientFactory) 38/// <summary>Builds an <see cref="IHostedFileClient"/> that represents the entire pipeline. Calls to this instance will pass through each of the pipeline stages in turn.</summary> 40/// The <see cref="IServiceProvider"/> that should provide services to the <see cref="IHostedFileClient"/> instances. 43/// <returns>An instance of <see cref="IHostedFileClient"/> that represents the entire pipeline.</returns> 45public IHostedFileClient Build(IServiceProvider? services = null) 48var fileClient = _innerClientFactory(services); 60$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(IHostedFileClient)} instances."); 72public HostedFileClientBuilder Use(Func<IHostedFileClient, IHostedFileClient> clientFactory) 83public HostedFileClientBuilder Use(Func<IHostedFileClient, IServiceProvider, IHostedFileClient> clientFactory)
Files\HostedFileClientBuilderHostedFileClientExtensions.cs (2)
10/// <summary>Provides extension methods for working with <see cref="IHostedFileClient"/> in the context of <see cref="HostedFileClientBuilder"/>.</summary> 21public static HostedFileClientBuilder AsBuilder(this IHostedFileClient innerClient)
Files\LoggingHostedFileClient.cs (3)
22/// The provided implementation of <see cref="IHostedFileClient"/> is thread-safe for concurrent use so long as the 42/// <param name="innerClient">The underlying <see cref="IHostedFileClient"/>.</param> 44public LoggingHostedFileClient(IHostedFileClient innerClient, ILogger logger)
Files\OpenTelemetryHostedFileClient.cs (2)
64/// <param name="innerClient">The underlying <see cref="IHostedFileClient"/>.</param> 67public OpenTelemetryHostedFileClient(IHostedFileClient innerClient, ILogger? logger = null, string? sourceName = null)
Microsoft.Extensions.AI.Abstractions (29)
Files\DelegatingHostedFileClient.cs (5)
16/// A delegating file client that wraps an inner <see cref="IHostedFileClient"/>. 20/// of another <see cref="IHostedFileClient"/>. By default, all methods delegate to the inner client. 30protected DelegatingHostedFileClient(IHostedFileClient innerClient) 35/// <summary>Gets the inner <see cref="IHostedFileClient"/>.</summary> 36protected IHostedFileClient InnerClient { get; }
Files\HostedFileClientExtensions.cs (15)
17/// Extension methods for <see cref="IHostedFileClient"/>. 33this IHostedFileClient client, 60this IHostedFileClient client, 94this IHostedFileClient client, 150this IHostedFileClient client, 180/// consider using <see cref="IHostedFileClient.DownloadAsync"/> 184this IHostedFileClient client, 203public static HostedFileClientMetadata? GetMetadata(this IHostedFileClient client) 218public static TService? GetService<TService>(this IHostedFileClient client, object? serviceKey = null) 226/// Asks the <see cref="IHostedFileClient"/> for an object of the specified type <paramref name="serviceType"/> 237/// The purpose of this method is to allow for the retrieval of services that are required to be provided by the <see cref="IHostedFileClient"/>, 240public static object GetRequiredService(this IHostedFileClient client, Type serviceType, object? serviceKey = null) 251/// Asks the <see cref="IHostedFileClient"/> for an object of type <typeparamref name="TService"/> 261/// The purpose of this method is to allow for the retrieval of strongly typed services that are required to be provided by the <see cref="IHostedFileClient"/>, 264public static TService GetRequiredService<TService>(this IHostedFileClient client, object? serviceKey = null)
Files\HostedFileClientMetadata.cs (1)
11/// Provides metadata about an <see cref="IHostedFileClient"/>.
Files\HostedFileClientOptions.cs (4)
76/// The underlying <see cref="IHostedFileClient" /> implementation may have its own representation of options. 79/// For situations where a consumer knows which concrete <see cref="IHostedFileClient" /> is being used 81/// by this callback, for the <see cref="IHostedFileClient" /> implementation to use instead of creating a new 90public Func<IHostedFileClient, object?>? RawRepresentationFactory { get; set; }
Files\IHostedFileClient.cs (4)
24/// Unless otherwise specified, all members of <see cref="IHostedFileClient"/> are thread-safe 25/// for concurrent use. It is expected that all implementations of <see cref="IHostedFileClient"/> 106/// Asks the <see cref="IHostedFileClient"/> for an object of the specified type <paramref name="serviceType"/>. 113/// The purpose of this method is to allow for the retrieval of strongly typed services that might be provided by the <see cref="IHostedFileClient"/>,
Microsoft.Extensions.AI.Abstractions.Tests (12)
Files\DelegatingHostedFileClientTests.cs (2)
178var client = delegating.GetService(typeof(IHostedFileClient)); 234private sealed class NoOpDelegatingHostedFileClient(IHostedFileClient innerClient)
Files\HostedFileClientExtensionsTests.cs (9)
48IHostedFileClient client = null!; 101IHostedFileClient client = null!; 254IHostedFileClient client = null!; 307IHostedFileClient client = null!; 381IHostedFileClient client = null!; 426IHostedFileClient client = null!; 468IHostedFileClient client = null!; 520IHostedFileClient client = null!; 554IHostedFileClient client = null!;
Files\HostedFileClientOptionsTests.cs (1)
36Func<IHostedFileClient, object?> factory = _ => "raw";
Microsoft.Extensions.AI.OpenAI (14)
OpenAIClientExtensions.cs (11)
195/// <summary>Gets an <see cref="IHostedFileClient"/> for use with this <see cref="OpenAIClient"/>.</summary> 197/// <returns>An <see cref="IHostedFileClient"/> that can be used to manage files via the <see cref="OpenAIClient"/>.</returns> 200/// The returned <see cref="IHostedFileClient"/> supports both the standard Files API and container files 205public static IHostedFileClient AsIHostedFileClient(this OpenAIClient openAIClient) => 208/// <summary>Gets an <see cref="IHostedFileClient"/> for use with this <see cref="OpenAIFileClient"/>.</summary> 210/// <returns>An <see cref="IHostedFileClient"/> that can be used to manage files via the <see cref="OpenAIFileClient"/>.</returns> 213/// The returned <see cref="IHostedFileClient"/> supports only the standard Files API. 218public static IHostedFileClient AsIHostedFileClient(this OpenAIFileClient fileClient) => 221/// <summary>Gets an <see cref="IHostedFileClient"/> for use with this <see cref="ContainerClient"/>.</summary> 227/// <returns>An <see cref="IHostedFileClient"/> that can be used to manage files within containers via the <see cref="ContainerClient"/>.</returns> 230public static IHostedFileClient AsIHostedFileClient(this ContainerClient containerClient, string? defaultScope = null) =>
OpenAIHostedFileClient.cs (3)
29/// An <see cref="IHostedFileClient"/> implementation for OpenAI file operations. 365$"Use an {nameof(IHostedFileClient)} created from an {nameof(OpenAIClient)} or {nameof(OpenAIFileClient)}, or set the Scope option to target a container instead."); 371$"Use an {nameof(IHostedFileClient)} created from an {nameof(OpenAIClient)} or {nameof(ContainerClient)} to access container files.");
Microsoft.Extensions.AI.OpenAI.Tests (60)
OpenAIHostedFileClientIntegrationTests.cs (4)
19private readonly IHostedFileClient? _client = IntegrationTestHelpers.GetOpenAIClient()?.AsIHostedFileClient(); 270using var containerClient = IntegrationTestHelpers.GetOpenAIClient()!.GetContainerClient().AsIHostedFileClient(); 343using var fileClient = IntegrationTestHelpers.GetOpenAIClient()!.GetContainerClient().AsIHostedFileClient(); 393using var fileClient = IntegrationTestHelpers.GetOpenAIClient()!.GetContainerClient().AsIHostedFileClient();
OpenAIHostedFileClientTests.cs (56)
51using IHostedFileClient fileClient = client.AsIHostedFileClient(); 65using IHostedFileClient fileClient = client.GetOpenAIFileClient().AsIHostedFileClient(); 79using IHostedFileClient fileClient = client.GetContainerClient().AsIHostedFileClient(); 109using IHostedFileClient client = CreateFileClient(httpClient); 146using IHostedFileClient client = CreateFileClient(httpClient); 160using IHostedFileClient client = CreateFileClient(httpClient); 169using IHostedFileClient client = CreateFileClient(httpClient); 178using IHostedFileClient client = CreateFileClient(httpClient); 199using IHostedFileClient client = CreateFileClient(httpClient); 218using IHostedFileClient client = CreateFileClient(httpClient); 229using IHostedFileClient client = CreateFileClient(httpClient); 238using IHostedFileClient client = CreateFileClient(httpClient); 258using IHostedFileClient client = CreateFileClient(httpClient); 295using IHostedFileClient client = CreateFileClient(httpClient); 316using IHostedFileClient client = CreateFileClient(httpClient); 338using IHostedFileClient client = CreateFileClient(httpClient); 350using IHostedFileClient client = CreateFileClient(httpClient); 361using IHostedFileClient client = CreateFileClient(httpClient); 370using IHostedFileClient client = CreateFileClient(httpClient); 379using IHostedFileClient client = CreateFileOnlyClient(httpClient); 390using IHostedFileClient client = CreateFileOnlyClient(httpClient); 400using IHostedFileClient client = CreateFileOnlyClient(httpClient); 410using IHostedFileClient client = CreateFileOnlyClient(httpClient); 420using IHostedFileClient client = CreateFileOnlyClient(httpClient); 430using IHostedFileClient client = CreateContainerClient(httpClient); 441using IHostedFileClient client = CreateContainerClient(httpClient); 451using IHostedFileClient client = CreateContainerClient(httpClient); 461using IHostedFileClient client = CreateContainerClient(httpClient); 471using IHostedFileClient client = CreateContainerClient(httpClient); 481using IHostedFileClient fileClient = client.AsIHostedFileClient(); 493using IHostedFileClient fileClient = client.AsIHostedFileClient(); 495var self = fileClient.GetService<IHostedFileClient>(); 504using IHostedFileClient fileClient = openAIClient.AsIHostedFileClient(); 515using IHostedFileClient fileClient = openAIClient.AsIHostedFileClient(); 526using IHostedFileClient fileClient = client.AsIHostedFileClient(); 537using IHostedFileClient fileClient = client.AsIHostedFileClient(); 548using IHostedFileClient fileClient = openAIClient.GetOpenAIFileClient().AsIHostedFileClient(); 559using IHostedFileClient fileClient = openAIClient.GetContainerClient().AsIHostedFileClient(); 588using IHostedFileClient client = CreateFileClient(httpClient); 622using IHostedFileClient client = CreateFileClient(httpClient); 639using IHostedFileClient fileClient = client.AsIHostedFileClient(); 659using IHostedFileClient client = CreateFileClient(httpClient); 684using IHostedFileClient client = CreateFileClient(httpClient); 714using IHostedFileClient client = CreateFileClient(httpClient); 741using IHostedFileClient client = CreateFileClient(httpClient); 756using IHostedFileClient client = CreateFileClient(httpClient); 783using IHostedFileClient client = CreateFileClient(httpClient); 807using IHostedFileClient client = CreateFileClient(httpClient); 819using IHostedFileClient client = CreateFileClient(httpClient); 844using IHostedFileClient client = CreateContainerClient(httpClient, defaultScope: "default-ctr"); 868using IHostedFileClient client = CreateFileClient(httpClient); 870IHostedFileClient? capturedClient = null; 886private static IHostedFileClient CreateFileClient(HttpClient httpClient) => 890private static IHostedFileClient CreateFileOnlyClient(HttpClient httpClient) => 895private static IHostedFileClient CreateContainerClient(HttpClient httpClient, string? defaultScope = null) =>
Microsoft.Extensions.AI.Tests (36)
Files\HostedFileClientBuilderTests.cs (8)
18Assert.Throws<ArgumentNullException>("innerClient", () => new HostedFileClientBuilder((IHostedFileClient)null!)); 19Assert.Throws<ArgumentNullException>("innerClientFactory", () => new HostedFileClientBuilder((Func<IServiceProvider, IHostedFileClient>)null!)); 23Assert.Throws<ArgumentNullException>("clientFactory", () => builder.Use((Func<IHostedFileClient, IHostedFileClient>)null!)); 24Assert.Throws<ArgumentNullException>("clientFactory", () => builder.Use((Func<IHostedFileClient, IServiceProvider, IHostedFileClient>)null!)); 97private sealed class InnerClientCapturingHostedFileClient(string name, IHostedFileClient innerClient) 101public new IHostedFileClient InnerClient => base.InnerClient;
Files\LoggingHostedFileClientTests.cs (13)
33Assert.Same(innerClient, innerClient.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(IHostedFileClient))); 64using IHostedFileClient client = innerClient 124using IHostedFileClient client = innerClient 173using IHostedFileClient client = innerClient 237using IHostedFileClient client = innerClient 290using IHostedFileClient client = innerClient 340using IHostedFileClient client = innerClient 370using IHostedFileClient client = innerClient 396using IHostedFileClient client = innerClient 425using IHostedFileClient client = innerClient 454using IHostedFileClient client = innerClient 483using IHostedFileClient client = innerClient 514using IHostedFileClient client = innerClient
Files\OpenTelemetryHostedFileClientTests.cs (15)
45using var client = innerClient 98using var client = innerClient 138using var client = innerClient 193using var client = innerClient 234using var client = innerClient 275using var client = innerClient 316using var client = innerClient 342using var client = innerClient 370using var client = innerClient 401using var client = innerClient 436using var client = innerClient 471using var client = innerClient 502using var client = innerClient 541using var client = innerClient 578using var client = innerClient