8 implementations of IChatClient
Microsoft.Extensions.AI.Abstractions (1)
ChatCompletion\DelegatingChatClient.cs (1)
19public class DelegatingChatClient : IChatClient
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestChatClient.cs (1)
11public sealed class TestChatClient : IChatClient
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
23public sealed class AzureAIInferenceChatClient : IChatClient
Microsoft.Extensions.AI.Integration.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (1)
11public sealed class TestChatClient : IChatClient
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
23public sealed class OllamaChatClient : IChatClient
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
27public sealed class OpenAIChatClient : IChatClient
Microsoft.Extensions.AI.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (1)
11public sealed class TestChatClient : IChatClient
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
17public abstract class CausalLMPipelineChatClient<TTokenizer, TCausalLMModel> : IChatClient
278 references to IChatClient
Aspire.Azure.AI.OpenAI.Tests (20)
AspireAzureOpenAIClientBuilderChatClientExtensionsTests.cs (20)
35var client = useKeyed ? 36host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 37host.Services.GetRequiredService<IChatClient>(); 65var client = useKeyed ? 66host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 67host.Services.GetRequiredService<IChatClient>(); 93var client = useKeyed ? 94host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 95host.Services.GetRequiredService<IChatClient>(); 125host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 126host.Services.GetRequiredService<IChatClient>(); 156host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 157host.Services.GetRequiredService<IChatClient>(); 186var client = useKeyed ? 187host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 188host.Services.GetRequiredService<IChatClient>(); 213var client = useKeyed ? 214host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 215host.Services.GetRequiredService<IChatClient>(); 220static Task<ChatCompletion> TestMiddleware(IList<ChatMessage> list, ChatOptions? options, IChatClient client, CancellationToken token)
Aspire.OpenAI (8)
AspireOpenAIClientBuilderChatClientExtensions.cs (8)
12/// Provides extension methods for registering <see cref="IChatClient"/> as a singleton in the services provided by the <see cref="IHostApplicationBuilder"/>. 17/// Registers a singleton <see cref="IChatClient"/> in the services provided by the <paramref name="builder"/>. 21/// <returns>A <see cref="ChatClientBuilder"/> that can be used to build a pipeline around the inner <see cref="IChatClient"/>.</returns> 31/// Registers a keyed singleton <see cref="IChatClient"/> in the services provided by the <paramref name="builder"/>. 34/// <param name="serviceKey">The service key with which the <see cref="IChatClient"/> will be registered.</param> 36/// <returns>A <see cref="ChatClientBuilder"/> that can be used to build a pipeline around the inner <see cref="IChatClient"/>.</returns> 47private static IChatClient CreateInnerChatClient( 57var result = openAiClient.AsChatClient(deploymentName);
Aspire.OpenAI.Tests (20)
AspireOpenAIClientBuilderChatClientExtensionsTests.cs (20)
36var client = useKeyed ? 37host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 38host.Services.GetRequiredService<IChatClient>(); 66var client = useKeyed ? 67host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 68host.Services.GetRequiredService<IChatClient>(); 94var client = useKeyed ? 95host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 96host.Services.GetRequiredService<IChatClient>(); 126host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 127host.Services.GetRequiredService<IChatClient>(); 157host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 158host.Services.GetRequiredService<IChatClient>(); 187var client = useKeyed ? 188host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 189host.Services.GetRequiredService<IChatClient>(); 214var client = useKeyed ? 215host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 216host.Services.GetRequiredService<IChatClient>(); 221static Task<ChatCompletion> TestMiddleware(IList<ChatMessage> list, ChatOptions? options, IChatClient client, CancellationToken token)
Microsoft.Extensions.AI (93)
ChatCompletion\AnonymousDelegatingChatClient.cs (10)
20private readonly Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatCompletion>>? _completeFunc; 28private readonly Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? _completeStreamingFunc; 48public AnonymousDelegatingChatClient(IChatClient innerClient, CompleteSharedFunc sharedFunc) 73IChatClient innerClient, 74Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatCompletion>>? completeFunc, 75Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? completeStreamingFunc) 196/// Represents a method used to call <see cref="IChatClient.CompleteAsync"/> or <see cref="IChatClient.CompleteStreamingAsync"/>. 201/// A delegate that provides the implementation for the inner client's <see cref="IChatClient.CompleteAsync"/> or 202/// <see cref="IChatClient.CompleteStreamingAsync"/>. It should be invoked to continue the pipeline. It accepts
ChatCompletion\CachingChatClient.cs (6)
27/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 28protected CachingChatClient(IChatClient innerClient) 135/// This is used when there is a call to <see cref="IChatClient.CompleteAsync(IList{ChatMessage}, ChatOptions?, CancellationToken)"/>. 144/// This is used when there is a call to <see cref="IChatClient.CompleteStreamingAsync(IList{ChatMessage}, ChatOptions?, CancellationToken)"/>. 153/// This is used when there is a call to <see cref="IChatClient.CompleteAsync(IList{ChatMessage}, ChatOptions?, CancellationToken)"/>. 163/// This is used when there is a call to <see cref="IChatClient.CompleteStreamingAsync(IList{ChatMessage}, ChatOptions?, CancellationToken)"/>.
ChatCompletion\ChatClientBuilder.cs (34)
12/// <summary>A builder for creating pipelines of <see cref="IChatClient"/>.</summary> 15private readonly Func<IServiceProvider, IChatClient> _innerClientFactory; 18private List<Func<IChatClient, IServiceProvider, IChatClient>>? _clientFactories; 21/// <param name="innerClient">The inner <see cref="IChatClient"/> that represents the underlying backend.</param> 22public ChatClientBuilder(IChatClient innerClient) 29/// <param name="innerClientFactory">A callback that produces the inner <see cref="IChatClient"/> that represents the underlying backend.</param> 30public ChatClientBuilder(Func<IServiceProvider, IChatClient> innerClientFactory) 35/// <summary>Builds an <see cref="IChatClient"/> that represents the entire pipeline. Calls to this instance will pass through each of the pipeline stages in turn.</summary> 37/// The <see cref="IServiceProvider"/> that should provide services to the <see cref="IChatClient"/> instances. 40/// <returns>An instance of <see cref="IChatClient"/> that represents the entire pipeline.</returns> 41public IChatClient Build(IServiceProvider? services = null) 44var chatClient = _innerClientFactory(services); 54$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(IChatClient)} instances."); 64public ChatClientBuilder Use(Func<IChatClient, IChatClient> clientFactory) 74public ChatClientBuilder Use(Func<IChatClient, IServiceProvider, IChatClient> clientFactory) 84/// an implementation for both <see cref="IChatClient.CompleteAsync"/> and <see cref="IChatClient.CompleteStreamingAsync"/>. 87/// A delegate that provides the implementation for both <see cref="IChatClient.CompleteAsync"/> and 88/// <see cref="IChatClient.CompleteStreamingAsync"/>. In addition to the arguments for the operation, it's 107/// an implementation for both <see cref="IChatClient.CompleteAsync"/> and <see cref="IChatClient.CompleteStreamingAsync"/>. 110/// A delegate that provides the implementation for <see cref="IChatClient.CompleteAsync"/>. When <see langword="null"/>, 111/// <paramref name="completeStreamingFunc"/> must be non-null, and the implementation of <see cref="IChatClient.CompleteAsync"/> 115/// A delegate that provides the implementation for <see cref="IChatClient.CompleteStreamingAsync"/>. When <see langword="null"/>, 116/// <paramref name="completeFunc"/> must be non-null, and the implementation of <see cref="IChatClient.CompleteStreamingAsync"/> 122/// <paramref name="completeFunc"/> will provide the implementation of <see cref="IChatClient.CompleteAsync"/>, and 123/// <paramref name="completeStreamingFunc"/> will provide the implementation of <see cref="IChatClient.CompleteStreamingAsync"/>. 125/// is supplied without <paramref name="completeStreamingFunc"/>, the implementation of <see cref="IChatClient.CompleteStreamingAsync"/> 128/// <see cref="IChatClient.CompleteAsync"/> will be implemented by combining the updates from <paramref name="completeStreamingFunc"/>. 132Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatCompletion>>? completeFunc, 133Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? completeStreamingFunc)
ChatCompletion\ChatClientBuilderChatClientExtensions.cs (2)
9/// <summary>Provides extension methods for working with <see cref="IChatClient"/> in the context of <see cref="ChatClientBuilder"/>.</summary> 19public static ChatClientBuilder AsBuilder(this IChatClient innerClient)
ChatCompletion\ChatClientBuilderServiceCollectionExtensions.cs (13)
10/// <summary>Provides extension methods for registering <see cref="IChatClient"/> with a <see cref="IServiceCollection"/>.</summary> 13/// <summary>Registers a singleton <see cref="IChatClient"/> in the <see cref="IServiceCollection"/>.</summary> 15/// <param name="innerClient">The inner <see cref="IChatClient"/> that represents the underlying backend.</param> 20IChatClient innerClient) 23/// <summary>Registers a singleton <see cref="IChatClient"/> in the <see cref="IServiceCollection"/>.</summary> 25/// <param name="innerClientFactory">A callback that produces the inner <see cref="IChatClient"/> that represents the underlying backend.</param> 30Func<IServiceProvider, IChatClient> innerClientFactory) 40/// <summary>Registers a keyed singleton <see cref="IChatClient"/> in the <see cref="IServiceCollection"/>.</summary> 43/// <param name="innerClient">The inner <see cref="IChatClient"/> that represents the underlying backend.</param> 49IChatClient innerClient) 52/// <summary>Registers a keyed singleton <see cref="IChatClient"/> in the <see cref="IServiceCollection"/>.</summary> 55/// <param name="innerClientFactory">A callback that produces the inner <see cref="IChatClient"/> that represents the underlying backend.</param> 61Func<IServiceProvider, IChatClient> innerClientFactory)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (9)
17/// Provides extension methods on <see cref="IChatClient"/> that simplify working with structured output. 29/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 45this IChatClient chatClient, 53/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 65this IChatClient chatClient, 73/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 86this IChatClient chatClient, 95/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 112this IChatClient chatClient,
ChatCompletion\ConfigureOptionsChatClient.cs (1)
30public ConfigureOptionsChatClient(IChatClient innerClient, Action<ChatOptions> configure)
ChatCompletion\DistributedCachingChatClient.cs (3)
18/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the employed 30/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 32public DistributedCachingChatClient(IChatClient innerClient, IDistributedCache storage)
ChatCompletion\DistributedCachingChatClientBuilderExtensions.cs (1)
12/// Extension methods for adding a <see cref="DistributedCachingChatClient"/> to an <see cref="IChatClient"/> pipeline.
ChatCompletion\FunctionInvokingChatClient.cs (9)
30/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the 56/// <param name="innerClient">The underlying <see cref="IChatClient"/>, or the next instance in a chain of clients.</param> 58public FunctionInvokingChatClient(IChatClient innerClient, ILogger? logger = null) 70/// underlying <see cref="IChatClient"/> will be instructed to give a response without invoking 72/// <see langword="true"/> if the underlying <see cref="IChatClient"/> is allowed 84/// in the chat history when calling the underlying <see cref="IChatClient"/>. 88/// when calling the underlying <see cref="IChatClient"/>. 100/// Setting the value to <see langword="true"/> can help the underlying <see cref="IChatClient"/> bypass problems on 138/// When the inner <see cref="IChatClient"/> returns <see cref="FunctionCallContent"/> to the
ChatCompletion\LoggingChatClient.cs (3)
17/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the 29/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 31public LoggingChatClient(IChatClient innerClient, ILogger logger)
ChatCompletion\OpenTelemetryChatClient.cs (2)
48/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 51public OpenTelemetryChatClient(IChatClient innerClient, ILogger? logger = null, string? sourceName = null)
Microsoft.Extensions.AI.Abstractions (24)
ChatCompletion\AutoChatToolMode.cs (1)
9/// Indicates that an <see cref="IChatClient"/> is free to select any of the available tools, or none at all.
ChatCompletion\ChatClientExtensions.cs (6)
11/// <summary>Provides a collection of static methods for extending <see cref="IChatClient"/> instances.</summary> 14/// <summary>Asks the <see cref="IChatClient"/> for an object of type <typeparamref name="TService"/>.</summary> 20/// The purpose of this method is to allow for the retrieval of strongly typed services that may be provided by the <see cref="IChatClient"/>, 23public static TService? GetService<TService>(this IChatClient client, object? serviceKey = null) 37this IChatClient client, 55this IChatClient client,
ChatCompletion\ChatClientMetadata.cs (1)
8/// <summary>Provides metadata about an <see cref="IChatClient"/>.</summary>
ChatCompletion\ChatMessage.cs (1)
11/// <summary>Represents a chat message used by an <see cref="IChatClient" />.</summary>
ChatCompletion\ChatToolMode.cs (2)
9/// Describes how tools should be selected by a <see cref="IChatClient"/>. 33/// instances, and the <see cref="IChatClient"/> is free to invoke zero or more of them.
ChatCompletion\DelegatingChatClient.cs (5)
13/// Provides an optional base class for an <see cref="IChatClient"/> that passes through calls to another instance. 16/// This is recommended as a base type when building clients that can be chained in any order around an underlying <see cref="IChatClient"/>. 25protected DelegatingChatClient(IChatClient innerClient) 37/// <summary>Gets the inner <see cref="IChatClient" />.</summary> 38protected IChatClient InnerClient { get; }
ChatCompletion\IChatClient.cs (7)
14/// Unless otherwise specified, all members of <see cref="IChatClient"/> are thread-safe for concurrent use. 15/// It is expected that all implementations of <see cref="IChatClient"/> support being used by multiple requests concurrently. 18/// However, implementations of <see cref="IChatClient"/> might mutate the arguments supplied to <see cref="CompleteAsync"/> and 21/// invocations or should otherwise ensure by construction that no <see cref="IChatClient"/> instances are used which might employ 56/// <summary>Gets metadata that describes the <see cref="IChatClient"/>.</summary> 59/// <summary>Asks the <see cref="IChatClient"/> for an object of the specified type <paramref name="serviceType"/>.</summary> 64/// The purpose of this method is to allow for the retrieval of strongly typed services that might be provided by the <see cref="IChatClient"/>,
ChatCompletion\StreamingChatCompletionUpdate.cs (1)
12/// Represents a single streaming response chunk from an <see cref="IChatClient"/>.
Microsoft.Extensions.AI.Abstractions.Tests (3)
ChatCompletion\DelegatingChatClientTests.cs (3)
135var client = delegating.GetService<IChatClient>(expectedKey); 172private sealed class NoOpDelegatingChatClient(IChatClient innerClient)
Microsoft.Extensions.AI.AzureAIInference (4)
AzureAIInferenceChatClient.cs (1)
22/// <summary>Represents an <see cref="IChatClient"/> for an Azure AI Inference <see cref="ChatCompletionsClient"/>.</summary>
AzureAIInferenceExtensions.cs (3)
11/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="ChatCompletionsClient"/>.</summary> 14/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="ChatCompletionsClient"/>.</returns> 15public static IChatClient AsChatClient(
Microsoft.Extensions.AI.AzureAIInference.Tests (13)
AzureAIInferenceChatClientIntegrationTests.cs (1)
10protected override IChatClient? CreateChatClient() =>
AzureAIInferenceChatClientTests.cs (12)
63IChatClient chatClient = client.AsChatClient(model); 73IChatClient chatClient = client.AsChatClient("model"); 75Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 80using IChatClient pipeline = chatClient 93Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 138using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 199using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 305using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 398using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 508using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 599using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 629private static IChatClient CreateChatClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Integration.Tests (5)
CallCountingChatClient.cs (1)
13internal sealed class CallCountingChatClient(IChatClient innerClient) : DelegatingChatClient(innerClient)
ChatClientIntegrationTests.cs (2)
30private readonly IChatClient? _chatClient; 43protected abstract IChatClient? CreateChatClient();
PromptBasedFunctionCallingChatClient.cs (1)
29internal sealed class PromptBasedFunctionCallingChatClient(IChatClient innerClient)
ReducingChatClientTests.cs (1)
20/// <summary>Provides an example of a custom <see cref="IChatClient"/> for reducing chat message lists.</summary>
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
22/// <summary>Represents an <see cref="IChatClient"/> for Ollama.</summary>
Microsoft.Extensions.AI.Ollama.Tests (12)
OllamaChatClientIntegrationTests.cs (4)
16protected override IChatClient? CreateChatClient() => 40using var chatClient = CreateChatClient()! 65using var chatClient = CreateChatClient()! 96private sealed class AssertNoToolsDefinedChatClient(IChatClient innerClient) : DelegatingChatClient(innerClient)
OllamaChatClientTests.cs (8)
49Assert.Same(client, client.GetService<IChatClient>()); 51using IChatClient pipeline = client 64Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 73using IChatClient chatClient = new OllamaChatClient(endpoint, model); 170using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient); 256using IChatClient client = new OllamaChatClient("http://localhost:11434", httpClient: httpClient); 360using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient) 452using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient)
Microsoft.Extensions.AI.OpenAI (7)
OpenAIChatClient.cs (1)
26/// <summary>Represents an <see cref="IChatClient"/> for an OpenAI <see cref="OpenAIClient"/> or <see cref="OpenAI.Chat.ChatClient"/>.</summary>
OpenAIClientExtensions.cs (6)
13/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="OpenAIClient"/>.</summary> 16/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="OpenAIClient"/>.</returns> 17public static IChatClient AsChatClient(this OpenAIClient openAIClient, string modelId) => 20/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="ChatClient"/>.</summary> 22/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="ChatClient"/>.</returns> 23public static IChatClient AsChatClient(this ChatClient chatClient) =>
Microsoft.Extensions.AI.OpenAI.Tests (19)
OpenAIChatClientIntegrationTests.cs (1)
10protected override IChatClient? CreateChatClient() =>
OpenAIChatClientTests.cs (18)
74IChatClient chatClient = client.AsChatClient(model); 89IChatClient chatClient = openAIClient.AsChatClient("model"); 91Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 98using IChatClient pipeline = chatClient 111Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 118IChatClient chatClient = openAIClient.AsChatClient(); 120Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 123using IChatClient pipeline = chatClient 136Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 181using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 246using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 351using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 452using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 543using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 656using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 750using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 883using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 925private static IChatClient CreateChatClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Tests (49)
ChatCompletion\ChatClientBuilderTest.cs (5)
61Assert.Throws<ArgumentNullException>("innerClient", () => new ChatClientBuilder((IChatClient)null!)); 62Assert.Throws<ArgumentNullException>("innerClient", () => ((IChatClient)null!).AsBuilder()); 68Assert.Throws<ArgumentNullException>("innerClientFactory", () => new ChatClientBuilder((Func<IServiceProvider, IChatClient>)null!)); 81private sealed class InnerClientCapturingChatClient(string name, IChatClient innerClient) : DelegatingChatClient(innerClient) 86public new IChatClient InnerClient => base.InnerClient;
ChatCompletion\ConfigureOptionsChatClientTests.cs (2)
41using IChatClient innerClient = new TestChatClient 58using var client = innerClient
ChatCompletion\DependencyInjectionPatterns.cs (28)
26var instance1 = scope1.ServiceProvider.GetRequiredService<IChatClient>(); 27var instance1Copy = scope1.ServiceProvider.GetRequiredService<IChatClient>(); 28var instance2 = scope2.ServiceProvider.GetRequiredService<IChatClient>(); 50var instance1 = scope1.ServiceProvider.GetRequiredService<IChatClient>(); 51var instance1Copy = scope1.ServiceProvider.GetRequiredService<IChatClient>(); 52var instance2 = scope2.ServiceProvider.GetRequiredService<IChatClient>(); 73Assert.Null(services.GetService<IChatClient>()); 75var instance1 = scope1.ServiceProvider.GetRequiredKeyedService<IChatClient>("mykey"); 76var instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<IChatClient>("mykey"); 77var instance2 = scope2.ServiceProvider.GetRequiredKeyedService<IChatClient>("mykey"); 99Assert.Null(services.GetService<IChatClient>()); 101var instance1 = scope1.ServiceProvider.GetRequiredKeyedService<IChatClient>("mykey"); 102var instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<IChatClient>("mykey"); 103var instance2 = scope2.ServiceProvider.GetRequiredKeyedService<IChatClient>("mykey"); 112public class SingletonMiddleware(IChatClient inner, IServiceProvider services) : DelegatingChatClient(inner) 114public new IChatClient InnerClient => base.InnerClient;
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
373IChatClient service = innerClient.AsBuilder().UseFunctionInvocation().Build(); 524IChatClient service = configurePipeline(innerClient.AsBuilder()).Build(services); 591IChatClient service = configurePipeline(innerClient.AsBuilder()).Build(services);
ChatCompletion\LoggingChatClientTests.cs (1)
36using IChatClient innerClient = new TestChatClient
ChatCompletion\UseDelegateChatClientTests.cs (10)
42using IChatClient innerClient = new TestChatClient 63using IChatClient client = new ChatClientBuilder(innerClient) 91using IChatClient innerClient = new TestChatClient 103using IChatClient client = new ChatClientBuilder(innerClient) 133using IChatClient innerClient = new TestChatClient 145using IChatClient client = new ChatClientBuilder(innerClient) 155IList<ChatMessage> chatMessages, ChatOptions? options, IChatClient innerClient, [EnumeratorCancellation] CancellationToken cancellationToken) 184using IChatClient innerClient = new TestChatClient 205using IChatClient client = new ChatClientBuilder(innerClient) 226IList<ChatMessage> chatMessages, ChatOptions? options, IChatClient innerClient, [EnumeratorCancellation] CancellationToken cancellationToken)