9 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)
25public 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)
24public sealed class OllamaChatClient : IChatClient
Microsoft.Extensions.AI.OpenAI (2)
OpenAIAssistantClient.cs (1)
28internal sealed class OpenAIAssistantClient : IChatClient
OpenAIChatClient.cs (1)
22public 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
361 references to IChatClient
Aspire.Azure.AI.OpenAI.Tests (23)
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<ChatResponse> TestMiddleware(IEnumerable<ChatMessage> list, ChatOptions? options, IChatClient client, CancellationToken token)
AspireConfigurableOpenAIExtensionsTests.cs (3)
243var chatClient = useKeyed ? 244host.Services.GetRequiredKeyedService<IChatClient>("chat") : 245host.Services.GetRequiredService<IChatClient>();
Aspire.OpenAI (8)
AspireOpenAIClientBuilderChatClientExtensions.cs (8)
13/// Provides extension methods for registering <see cref="IChatClient"/> as a singleton in the services provided by the <see cref="IHostApplicationBuilder"/>. 18/// Registers a singleton <see cref="IChatClient"/> in the services provided by the <paramref name="builder"/>. 22/// <returns>A <see cref="ChatClientBuilder"/> that can be used to build a pipeline around the inner <see cref="IChatClient"/>.</returns> 34/// Registers a keyed singleton <see cref="IChatClient"/> in the services provided by the <paramref name="builder"/>. 37/// <param name="serviceKey">The service key with which the <see cref="IChatClient"/> will be registered.</param> 39/// <returns>A <see cref="ChatClientBuilder"/> that can be used to build a pipeline around the inner <see cref="IChatClient"/>.</returns> 58private static IChatClient CreateInnerChatClient( 68var result = openAiClient.AsChatClient(deploymentName);
Aspire.OpenAI.Tests (23)
AspireOpenAIClientBuilderChatClientExtensionsTests.cs (23)
38var client = useKeyed ? 39host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 40host.Services.GetRequiredService<IChatClient>(); 68var client = useKeyed ? 69host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 70host.Services.GetRequiredService<IChatClient>(); 96var client = useKeyed ? 97host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 98host.Services.GetRequiredService<IChatClient>(); 128host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 129host.Services.GetRequiredService<IChatClient>(); 159host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 160host.Services.GetRequiredService<IChatClient>(); 189var client = useKeyed ? 190host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 191host.Services.GetRequiredService<IChatClient>(); 216var client = useKeyed ? 217host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 218host.Services.GetRequiredService<IChatClient>(); 249var client = useKeyed ? 250host.Services.GetRequiredKeyedService<IChatClient>("openai_chatclient") : 251host.Services.GetRequiredService<IChatClient>(); 268private static Task<ChatResponse> TestMiddleware(IEnumerable<ChatMessage> list, ChatOptions? options, IChatClient client, CancellationToken token)
Microsoft.Extensions.AI (96)
ChatCompletion\AnonymousDelegatingChatClient.cs (6)
20private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? _getResponseFunc; 28private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc; 49IChatClient innerClient, 75IChatClient innerClient, 76Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc, 77Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
ChatCompletion\CachingChatClient.cs (6)
27/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 28protected CachingChatClient(IChatClient innerClient) 138/// This is used when there is a call to <see cref="IChatClient.GetResponseAsync"/>. 148/// This is used when there is a call to <see cref="IChatClient.GetStreamingResponseAsync"/>. 158/// This is used when there is a call to <see cref="IChatClient.GetResponseAsync"/>. 170/// This is used when there is a call to <see cref="IChatClient.GetStreamingResponseAsync"/>.
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> 23public ChatClientBuilder(IChatClient innerClient) 30/// <param name="innerClientFactory">A callback that produces the inner <see cref="IChatClient"/> that represents the underlying backend.</param> 31public ChatClientBuilder(Func<IServiceProvider, IChatClient> innerClientFactory) 36/// <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> 38/// The <see cref="IServiceProvider"/> that should provide services to the <see cref="IChatClient"/> instances. 41/// <returns>An instance of <see cref="IChatClient"/> that represents the entire pipeline.</returns> 42public IChatClient Build(IServiceProvider? services = null) 45var chatClient = _innerClientFactory(services); 57$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(IChatClient)} instances."); 69public ChatClientBuilder Use(Func<IChatClient, IChatClient> clientFactory) 80public ChatClientBuilder Use(Func<IChatClient, IServiceProvider, IChatClient> clientFactory) 90/// an implementation for both <see cref="IChatClient.GetResponseAsync"/> and <see cref="IChatClient.GetStreamingResponseAsync"/>. 93/// A delegate that provides the implementation for both <see cref="IChatClient.GetResponseAsync"/> and 94/// <see cref="IChatClient.GetStreamingResponseAsync"/>. This delegate is invoked with the list of chat messages, the chat 114/// an implementation for both <see cref="IChatClient.GetResponseAsync"/> and <see cref="IChatClient.GetStreamingResponseAsync"/>. 117/// A delegate that provides the implementation for <see cref="IChatClient.GetResponseAsync"/>. When <see langword="null"/>, 118/// <paramref name="getStreamingResponseFunc"/> must be non-null, and the implementation of <see cref="IChatClient.GetResponseAsync"/> 122/// A delegate that provides the implementation for <see cref="IChatClient.GetStreamingResponseAsync"/>. When <see langword="null"/>, 123/// <paramref name="getResponseFunc"/> must be non-null, and the implementation of <see cref="IChatClient.GetStreamingResponseAsync"/> 129/// <paramref name="getResponseFunc"/> will provide the implementation of <see cref="IChatClient.GetResponseAsync"/>, and 130/// <paramref name="getStreamingResponseFunc"/> will provide the implementation of <see cref="IChatClient.GetStreamingResponseAsync"/>. 132/// is supplied without <paramref name="getStreamingResponseFunc"/>, the implementation of <see cref="IChatClient.GetStreamingResponseAsync"/> 135/// <see cref="IChatClient.GetResponseAsync"/> will be implemented by combining the updates from <paramref name="getStreamingResponseFunc"/>. 139Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc, 140Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
ChatCompletion\ChatClientBuilderChatClientExtensions.cs (2)
10/// <summary>Provides extension methods for working with <see cref="IChatClient"/> in the context of <see cref="ChatClientBuilder"/>.</summary> 21public static ChatClientBuilder AsBuilder(this IChatClient innerClient)
ChatCompletion\ChatClientBuilderServiceCollectionExtensions.cs (15)
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> 23IChatClient innerClient, 32/// <summary>Registers a singleton <see cref="IChatClient"/> in the <see cref="IServiceCollection"/>.</summary> 34/// <param name="innerClientFactory">A callback that produces the inner <see cref="IChatClient"/> that represents the underlying backend.</param> 42Func<IServiceProvider, IChatClient> innerClientFactory, 49serviceCollection.Add(new ServiceDescriptor(typeof(IChatClient), builder.Build, lifetime)); 53/// <summary>Registers a keyed singleton <see cref="IChatClient"/> in the <see cref="IServiceCollection"/>.</summary> 56/// <param name="innerClient">The inner <see cref="IChatClient"/> that represents the underlying backend.</param> 65IChatClient innerClient, 74/// <summary>Registers a keyed singleton <see cref="IChatClient"/> in the <see cref="IServiceCollection"/>.</summary> 77/// <param name="innerClientFactory">A callback that produces the inner <see cref="IChatClient"/> that represents the underlying backend.</param> 86Func<IServiceProvider, IChatClient> innerClientFactory, 93serviceCollection.Add(new ServiceDescriptor(typeof(IChatClient), serviceKey, factory: (services, serviceKey) => builder.Build(services), lifetime));
ChatCompletion\ChatClientStructuredOutputExtensions.cs (13)
19/// Provides extension methods on <see cref="IChatClient"/> that simplify working with structured output. 31/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 43this IChatClient chatClient, 51/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 63this IChatClient chatClient, 71/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 83this IChatClient chatClient, 91/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 104this IChatClient chatClient, 113/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 126this IChatClient chatClient, 135/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 151this IChatClient chatClient,
ChatCompletion\ConfigureOptionsChatClient.cs (1)
30public ConfigureOptionsChatClient(IChatClient innerClient, Action<ChatOptions> configure)
ChatCompletion\DistributedCachingChatClient.cs (3)
22/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the employed 34/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 36public 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 (10)
35/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the 64/// <param name="innerClient">The underlying <see cref="IChatClient"/>, or the next instance in a chain of clients.</param> 66public FunctionInvokingChatClient(IChatClient innerClient, ILogger? logger = null) 90/// underlying <see cref="IChatClient"/> will be instructed to give a response without invoking 92/// <see langword="true"/> if the underlying <see cref="IChatClient"/> is allowed 104/// in the chat history when calling the underlying <see cref="IChatClient"/>. 108/// when calling the underlying <see cref="IChatClient"/>. 120/// Setting the value to <see langword="true"/> can help the underlying <see cref="IChatClient"/> bypass problems on 208Throw.InvalidOperationException($"The inner {nameof(IChatClient)} returned a null {nameof(ChatResponse)}."); 294Throw.InvalidOperationException($"The inner {nameof(IChatClient)} streamed a null {nameof(ChatResponseUpdate)}.");
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 (40)
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 (14)
12/// <summary>Provides a collection of static methods for extending <see cref="IChatClient"/> instances.</summary> 15/// <summary>Asks the <see cref="IChatClient"/> for an object of type <typeparamref name="TService"/>.</summary> 22/// The purpose of this method is to allow for the retrieval of strongly typed services that may be provided by the <see cref="IChatClient"/>, 25public static TService? GetService<TService>(this IChatClient client, object? serviceKey = null) 33/// Asks the <see cref="IChatClient"/> for an object of the specified type <paramref name="serviceType"/> 44/// The purpose of this method is to allow for the retrieval of services that are required to be provided by the <see cref="IChatClient"/>, 47public static object GetRequiredService(this IChatClient client, Type serviceType, object? serviceKey = null) 58/// Asks the <see cref="IChatClient"/> for an object of type <typeparamref name="TService"/> 68/// 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="IChatClient"/>, 71public static TService GetRequiredService<TService>(this IChatClient client, object? serviceKey = null) 92this IChatClient client, 112this IChatClient client, 132this IChatClient client, 152this IChatClient client,
ChatCompletion\ChatClientMetadata.cs (1)
8/// <summary>Provides metadata about an <see cref="IChatClient"/>.</summary>
ChatCompletion\ChatMessage.cs (1)
12/// <summary>Represents a chat message used by an <see cref="IChatClient" />.</summary>
ChatCompletion\ChatResponse.cs (4)
17/// request to a <see cref="IChatClient"/> may actually generate multiple roundtrips to an inner <see cref="IChatClient"/> 68/// Some <see cref="IChatClient"/> implementations are capable of storing the state for a chat thread, such that 69/// the input messages supplied to <see cref="IChatClient.GetResponseAsync"/> need only be the additional messages beyond
ChatCompletion\ChatResponseUpdate.cs (3)
13/// Represents a single streaming response chunk from an <see cref="IChatClient"/>. 112/// Some <see cref="IChatClient"/> implementations are capable of storing the state for a chat thread, such that 113/// the input messages supplied to <see cref="IChatClient.GetStreamingResponseAsync"/> need only be the additional messages beyond
ChatCompletion\ChatToolMode.cs (4)
9/// Describes how tools should be selected by a <see cref="IChatClient"/>. 34/// instances, and the <see cref="IChatClient"/> is free to invoke zero or more of them. 43/// instances, but the <see cref="IChatClient"/> should not request the invocation of 44/// any of them. This can be used when the <see cref="IChatClient"/> should know about
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 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 (6)
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. 19/// However, implementations of <see cref="IChatClient"/> might mutate the arguments supplied to <see cref="GetResponseAsync"/> and 22/// that no <see cref="IChatClient"/> instances are used which might employ such mutation. For example, the ConfigureOptions method is 50/// <summary>Asks the <see cref="IChatClient"/> for an object of the specified type <paramref name="serviceType"/>.</summary> 56/// 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\NoneChatToolMode.cs (1)
9/// Indicates that an <see cref="IChatClient"/> should not request the invocation of any tools.
Microsoft.Extensions.AI.Abstractions.Tests (6)
ChatCompletion\ChatClientExtensionsTests.cs (3)
42if (serviceType == typeof(IChatClient)) 57Assert.Null(client.GetService<IChatClient>()); 69Assert.Throws<InvalidOperationException>(() => client.GetRequiredService<IChatClient>());
ChatCompletion\DelegatingChatClientTests.cs (3)
126var client = delegating.GetService<IChatClient>(expectedKey); 163private sealed class NoOpDelegatingChatClient(IChatClient innerClient)
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (2)
24/// <summary>Represents an <see cref="IChatClient"/> for an Azure AI Inference <see cref="ChatCompletionsClient"/>.</summary> 73object? IChatClient.GetService(Type serviceType, object? serviceKey)
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 (18)
AzureAIInferenceChatClientIntegrationTests.cs (1)
8protected override IChatClient? CreateChatClient() =>
AzureAIInferenceChatClientTests.cs (17)
65IChatClient chatClient = client.AsChatClient(model); 76IChatClient chatClient = client.AsChatClient("model"); 78Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 83using IChatClient pipeline = chatClient 97Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 153using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 225using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 293using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 341using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 377using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 434using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 531using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 613using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 676using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 795using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 881using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 911private static IChatClient CreateChatClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Evaluation (13)
ChatConfiguration.cs (5)
12/// Specifies the <see cref="IChatClient"/> and the <see cref="IEvaluationTokenCounter"/> that should be used when 15/// <param name="chatClient">An <see cref="IChatClient"/> that can be used to communicate with an AI model.</param> 20public sealed class ChatConfiguration(IChatClient chatClient, IEvaluationTokenCounter? tokenCounter = null) 23/// Gets an <see cref="IChatClient"/> that can be used to communicate with an AI model. 25public IChatClient ChatClient { get; } = chatClient;
CompositeEvaluator.cs (1)
91/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
EvaluatorExtensions.cs (6)
33/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 76/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 118/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 163/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 211/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 260/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
IEvaluator.cs (1)
40/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
Microsoft.Extensions.AI.Evaluation.Integration.Tests (5)
AdditionalContextTests.cs (2)
55IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient; 90IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient;
EndToEndTests.cs (2)
65IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient; 116IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient;
Setup.cs (1)
26IChatClient chatClient = azureClient.AsChatClient(Settings.Current.DeploymentName);
Microsoft.Extensions.AI.Evaluation.Quality (2)
ChatConversationEvaluator.cs (2)
200/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 355/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
Microsoft.Extensions.AI.Evaluation.Reporting (12)
ReportingConfiguration.cs (5)
32/// Gets a <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 51/// the configured <see cref="IChatClient"/> and the <see cref="ChatOptions"/> that are supplied as part of 99/// A <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 175IChatClient originalChatClient = chatConfiguration.ChatClient; 216private static IEnumerable<string> GetCachingKeysForChatClient(IChatClient chatClient)
ResponseCachingChatClient.cs (5)
11/// An <see cref="IChatClient"/> that wraps another <see cref="IChatClient"/> and caches all responses generated using 12/// the wrapped <see cref="IChatClient"/> in the supplied <see cref="IDistributedCache"/>. 23/// <param name="originalChatClient">The <see cref="IChatClient"/> that is wrapped.</param> 30IChatClient originalChatClient,
ScenarioRun.cs (1)
79/// Gets a <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
Storage\DiskBasedReportingConfiguration.cs (1)
27/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (1)
Storage\AzureStorageReportingConfiguration.cs (1)
32/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
Microsoft.Extensions.AI.Integration.Tests (7)
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)
32internal sealed class PromptBasedFunctionCallingChatClient(IChatClient innerClient)
ReducingChatClientTests.cs (3)
20/// <summary>Provides an example of a custom <see cref="IChatClient"/> for reducing chat message lists.</summary> 40using var client = innerClient 68public ReducingChatClient(IChatClient innerClient, IChatReducer reducer)
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
23/// <summary>Represents an <see cref="IChatClient"/> for Ollama.</summary> 200object? IChatClient.GetService(Type serviceType, object? serviceKey)
Microsoft.Extensions.AI.Ollama.Tests (12)
OllamaChatClientIntegrationTests.cs (4)
16protected override IChatClient? CreateChatClient() => 34using var chatClient = CreateChatClient()! 58using var chatClient = CreateChatClient()! 106private 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); 171using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient); 263using IChatClient client = new OllamaChatClient("http://localhost:11434", httpClient: httpClient); 367using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient) 458using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient)
Microsoft.Extensions.AI.OpenAI (12)
OpenAIAssistantClient.cs (1)
27/// <summary>Represents an <see cref="IChatClient"/> for an OpenAI <see cref="OpenAIClient"/> or <see cref="ChatClient"/>.</summary>
OpenAIChatClient.cs (2)
21/// <summary>Represents an <see cref="IChatClient"/> for an OpenAI <see cref="OpenAIClient"/> or <see cref="ChatClient"/>.</summary> 91object? IChatClient.GetService(Type serviceType, object? serviceKey)
OpenAIClientExtensions.cs (9)
14/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="OpenAIClient"/>.</summary> 17/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="OpenAIClient"/>.</returns> 18public static IChatClient AsChatClient(this OpenAIClient openAIClient, string modelId) => 21/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="ChatClient"/>.</summary> 23/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="ChatClient"/>.</returns> 24public static IChatClient AsChatClient(this ChatClient chatClient) => 28/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="AssistantClient"/>.</summary> 35/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="ChatClient"/>.</returns> 36public static IChatClient AsChatClient(this AssistantClient assistantClient, string assistantId, string? threadId = null) =>
Microsoft.Extensions.AI.OpenAI.Tests (20)
OpenAIChatClientIntegrationTests.cs (1)
8protected override IChatClient? CreateChatClient() =>
OpenAIChatClientTests.cs (19)
74IChatClient chatClient = client.AsChatClient(model); 91IChatClient chatClient = openAIClient.AsChatClient("model"); 93Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 100using IChatClient pipeline = chatClient 113Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 120IChatClient chatClient = openAIClient.AsChatClient(); 122Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 125using IChatClient pipeline = chatClient 138Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 188using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 268using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 348using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 437using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 546using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 645using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 766using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 869using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 1010using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 1060private static IChatClient CreateChatClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Tests (56)
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!)); 99private sealed class InnerClientCapturingChatClient(string name, IChatClient innerClient) : DelegatingChatClient(innerClient) 104public new IChatClient InnerClient => base.InnerClient;
ChatCompletion\ConfigureOptionsChatClientTests.cs (2)
41using IChatClient innerClient = new TestChatClient 58using var client = innerClient
ChatCompletion\DependencyInjectionPatterns.cs (30)
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"); 126Assert.Equal(typeof(IChatClient), sd.ServiceType); 148Assert.Equal(typeof(IChatClient), sd.ServiceType); 248public class SingletonMiddleware(IChatClient inner, IServiceProvider services) : DelegatingChatClient(inner) 250public new IChatClient InnerClient => base.InnerClient;
ChatCompletion\DistributedCachingChatClientTest.cs (1)
799private sealed class CachingChatClientWithCustomKey(IChatClient innerClient, IDistributedCache storage)
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
600using IChatClient service = innerClient.AsBuilder().UseFunctionInvocation().Build(); 639IChatClient service = configurePipeline(innerClient.AsBuilder()).Build(services); 730IChatClient service = configurePipeline(innerClient.AsBuilder()).Build(services);
ChatCompletion\LoggingChatClientTests.cs (5)
30Assert.Same(innerClient, innerClient.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(IChatClient))); 55using IChatClient innerClient = new TestChatClient 63using IChatClient client = innerClient 100using IChatClient innerClient = new TestChatClient 112using IChatClient client = innerClient
ChatCompletion\UseDelegateChatClientTests.cs (10)
34using IChatClient innerClient = new TestChatClient 55using IChatClient client = new ChatClientBuilder(innerClient) 83using IChatClient innerClient = new TestChatClient 95using IChatClient client = new ChatClientBuilder(innerClient) 125using IChatClient innerClient = new TestChatClient 137using IChatClient client = new ChatClientBuilder(innerClient) 147IEnumerable<ChatMessage> messages, ChatOptions? options, IChatClient innerClient, [EnumeratorCancellation] CancellationToken cancellationToken) 176using IChatClient innerClient = new TestChatClient 197using IChatClient client = new ChatClientBuilder(innerClient) 218IEnumerable<ChatMessage> messages, ChatOptions? options, IChatClient innerClient, [EnumeratorCancellation] CancellationToken cancellationToken)