4 implementations of IHostedFileClient
Microsoft.Extensions.AI.Abstractions (1)
Files\DelegatingHostedFileClient.cs (1)
23
public class DelegatingHostedFileClient :
IHostedFileClient
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestHostedFileClient.cs (1)
14
internal sealed class TestHostedFileClient :
IHostedFileClient
Microsoft.Extensions.AI.OpenAI (1)
OpenAIHostedFileClient.cs (1)
44
internal sealed class OpenAIHostedFileClient :
IHostedFileClient
Microsoft.Extensions.AI.Tests (1)
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestHostedFileClient.cs (1)
14
internal 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>
16
private readonly Func<IServiceProvider,
IHostedFileClient
> _innerClientFactory;
19
private List<Func<
IHostedFileClient
, IServiceProvider,
IHostedFileClient
>>? _clientFactories;
22
/// <param name="innerClient">The inner <see cref="
IHostedFileClient
"/> that represents the underlying backend.</param>
24
public HostedFileClientBuilder(
IHostedFileClient
innerClient)
31
/// <param name="innerClientFactory">A callback that produces the inner <see cref="
IHostedFileClient
"/> that represents the underlying backend.</param>
33
public 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>
45
public
IHostedFileClient
Build(IServiceProvider? services = null)
48
var
fileClient = _innerClientFactory(services);
60
$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(
IHostedFileClient
)} instances.");
72
public HostedFileClientBuilder Use(Func<
IHostedFileClient
,
IHostedFileClient
> clientFactory)
83
public 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>
21
public 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>
44
public LoggingHostedFileClient(
IHostedFileClient
innerClient, ILogger logger)
Files\OpenTelemetryHostedFileClient.cs (2)
64
/// <param name="innerClient">The underlying <see cref="
IHostedFileClient
"/>.</param>
67
public 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.
30
protected DelegatingHostedFileClient(
IHostedFileClient
innerClient)
35
/// <summary>Gets the inner <see cref="
IHostedFileClient
"/>.</summary>
36
protected
IHostedFileClient
InnerClient { get; }
Files\HostedFileClientExtensions.cs (15)
17
/// Extension methods for <see cref="
IHostedFileClient
"/>.
33
this
IHostedFileClient
client,
60
this
IHostedFileClient
client,
94
this
IHostedFileClient
client,
150
this
IHostedFileClient
client,
180
/// consider using <see cref="
IHostedFileClient
.DownloadAsync"/>
184
this
IHostedFileClient
client,
203
public static HostedFileClientMetadata? GetMetadata(this
IHostedFileClient
client)
218
public 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
"/>,
240
public 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
"/>,
264
public 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
90
public 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)
178
var client = delegating.GetService(typeof(
IHostedFileClient
));
234
private sealed class NoOpDelegatingHostedFileClient(
IHostedFileClient
innerClient)
Files\HostedFileClientExtensionsTests.cs (9)
48
IHostedFileClient
client = null!;
101
IHostedFileClient
client = null!;
254
IHostedFileClient
client = null!;
307
IHostedFileClient
client = null!;
381
IHostedFileClient
client = null!;
426
IHostedFileClient
client = null!;
468
IHostedFileClient
client = null!;
520
IHostedFileClient
client = null!;
554
IHostedFileClient
client = null!;
Files\HostedFileClientOptionsTests.cs (1)
36
Func<
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
205
public 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.
218
public 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>
230
public 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)
19
private readonly
IHostedFileClient
? _client = IntegrationTestHelpers.GetOpenAIClient()?.AsIHostedFileClient();
270
using
var
containerClient = IntegrationTestHelpers.GetOpenAIClient()!.GetContainerClient().AsIHostedFileClient();
343
using
var
fileClient = IntegrationTestHelpers.GetOpenAIClient()!.GetContainerClient().AsIHostedFileClient();
393
using
var
fileClient = IntegrationTestHelpers.GetOpenAIClient()!.GetContainerClient().AsIHostedFileClient();
OpenAIHostedFileClientTests.cs (56)
51
using
IHostedFileClient
fileClient = client.AsIHostedFileClient();
65
using
IHostedFileClient
fileClient = client.GetOpenAIFileClient().AsIHostedFileClient();
79
using
IHostedFileClient
fileClient = client.GetContainerClient().AsIHostedFileClient();
109
using
IHostedFileClient
client = CreateFileClient(httpClient);
146
using
IHostedFileClient
client = CreateFileClient(httpClient);
160
using
IHostedFileClient
client = CreateFileClient(httpClient);
169
using
IHostedFileClient
client = CreateFileClient(httpClient);
178
using
IHostedFileClient
client = CreateFileClient(httpClient);
199
using
IHostedFileClient
client = CreateFileClient(httpClient);
218
using
IHostedFileClient
client = CreateFileClient(httpClient);
229
using
IHostedFileClient
client = CreateFileClient(httpClient);
238
using
IHostedFileClient
client = CreateFileClient(httpClient);
258
using
IHostedFileClient
client = CreateFileClient(httpClient);
295
using
IHostedFileClient
client = CreateFileClient(httpClient);
316
using
IHostedFileClient
client = CreateFileClient(httpClient);
338
using
IHostedFileClient
client = CreateFileClient(httpClient);
350
using
IHostedFileClient
client = CreateFileClient(httpClient);
361
using
IHostedFileClient
client = CreateFileClient(httpClient);
370
using
IHostedFileClient
client = CreateFileClient(httpClient);
379
using
IHostedFileClient
client = CreateFileOnlyClient(httpClient);
390
using
IHostedFileClient
client = CreateFileOnlyClient(httpClient);
400
using
IHostedFileClient
client = CreateFileOnlyClient(httpClient);
410
using
IHostedFileClient
client = CreateFileOnlyClient(httpClient);
420
using
IHostedFileClient
client = CreateFileOnlyClient(httpClient);
430
using
IHostedFileClient
client = CreateContainerClient(httpClient);
441
using
IHostedFileClient
client = CreateContainerClient(httpClient);
451
using
IHostedFileClient
client = CreateContainerClient(httpClient);
461
using
IHostedFileClient
client = CreateContainerClient(httpClient);
471
using
IHostedFileClient
client = CreateContainerClient(httpClient);
481
using
IHostedFileClient
fileClient = client.AsIHostedFileClient();
493
using
IHostedFileClient
fileClient = client.AsIHostedFileClient();
495
var
self = fileClient.GetService<
IHostedFileClient
>();
504
using
IHostedFileClient
fileClient = openAIClient.AsIHostedFileClient();
515
using
IHostedFileClient
fileClient = openAIClient.AsIHostedFileClient();
526
using
IHostedFileClient
fileClient = client.AsIHostedFileClient();
537
using
IHostedFileClient
fileClient = client.AsIHostedFileClient();
548
using
IHostedFileClient
fileClient = openAIClient.GetOpenAIFileClient().AsIHostedFileClient();
559
using
IHostedFileClient
fileClient = openAIClient.GetContainerClient().AsIHostedFileClient();
588
using
IHostedFileClient
client = CreateFileClient(httpClient);
622
using
IHostedFileClient
client = CreateFileClient(httpClient);
639
using
IHostedFileClient
fileClient = client.AsIHostedFileClient();
659
using
IHostedFileClient
client = CreateFileClient(httpClient);
684
using
IHostedFileClient
client = CreateFileClient(httpClient);
714
using
IHostedFileClient
client = CreateFileClient(httpClient);
741
using
IHostedFileClient
client = CreateFileClient(httpClient);
756
using
IHostedFileClient
client = CreateFileClient(httpClient);
783
using
IHostedFileClient
client = CreateFileClient(httpClient);
807
using
IHostedFileClient
client = CreateFileClient(httpClient);
819
using
IHostedFileClient
client = CreateFileClient(httpClient);
844
using
IHostedFileClient
client = CreateContainerClient(httpClient, defaultScope: "default-ctr");
868
using
IHostedFileClient
client = CreateFileClient(httpClient);
870
IHostedFileClient
? capturedClient = null;
886
private static
IHostedFileClient
CreateFileClient(HttpClient httpClient) =>
890
private static
IHostedFileClient
CreateFileOnlyClient(HttpClient httpClient) =>
895
private static
IHostedFileClient
CreateContainerClient(HttpClient httpClient, string? defaultScope = null) =>
Microsoft.Extensions.AI.Tests (36)
Files\HostedFileClientBuilderTests.cs (8)
18
Assert.Throws<ArgumentNullException>("innerClient", () => new HostedFileClientBuilder((
IHostedFileClient
)null!));
19
Assert.Throws<ArgumentNullException>("innerClientFactory", () => new HostedFileClientBuilder((Func<IServiceProvider,
IHostedFileClient
>)null!));
23
Assert.Throws<ArgumentNullException>("clientFactory", () => builder.Use((Func<
IHostedFileClient
,
IHostedFileClient
>)null!));
24
Assert.Throws<ArgumentNullException>("clientFactory", () => builder.Use((Func<
IHostedFileClient
, IServiceProvider,
IHostedFileClient
>)null!));
97
private sealed class InnerClientCapturingHostedFileClient(string name,
IHostedFileClient
innerClient)
101
public new
IHostedFileClient
InnerClient => base.InnerClient;
Files\LoggingHostedFileClientTests.cs (13)
33
Assert.Same(innerClient, innerClient.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(
IHostedFileClient
)));
64
using
IHostedFileClient
client = innerClient
124
using
IHostedFileClient
client = innerClient
173
using
IHostedFileClient
client = innerClient
237
using
IHostedFileClient
client = innerClient
290
using
IHostedFileClient
client = innerClient
340
using
IHostedFileClient
client = innerClient
370
using
IHostedFileClient
client = innerClient
396
using
IHostedFileClient
client = innerClient
425
using
IHostedFileClient
client = innerClient
454
using
IHostedFileClient
client = innerClient
483
using
IHostedFileClient
client = innerClient
514
using
IHostedFileClient
client = innerClient
Files\OpenTelemetryHostedFileClientTests.cs (15)
45
using
var
client = innerClient
98
using
var
client = innerClient
138
using
var
client = innerClient
193
using
var
client = innerClient
234
using
var
client = innerClient
275
using
var
client = innerClient
316
using
var
client = innerClient
342
using
var
client = innerClient
370
using
var
client = innerClient
401
using
var
client = innerClient
436
using
var
client = innerClient
471
using
var
client = innerClient
502
using
var
client = innerClient
541
using
var
client = innerClient
578
using
var
client = innerClient