10 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)
25internal sealed class AzureAIInferenceChatClient : IChatClient
Microsoft.Extensions.AI.Evaluation.Safety (1)
ContentSafetyChatClient.cs (1)
19internal sealed class ContentSafetyChatClient : 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)
OpenAIChatClient.cs (1)
25internal sealed partial class OpenAIChatClient : IChatClient
OpenAIResponseChatClient.cs (1)
25internal sealed partial class OpenAIResponseChatClient : 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
388 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.GetChatClient(deploymentName).AsIChatClient();
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 (95)
ChatCompletion\AnonymousDelegatingChatClient.cs (6)
23private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? _getResponseFunc; 31private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc; 52IChatClient innerClient, 78IChatClient innerClient, 79Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc, 80Func<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) 140/// This is used when there is a call to <see cref="IChatClient.GetResponseAsync"/>. 150/// This is used when there is a call to <see cref="IChatClient.GetStreamingResponseAsync"/>. 160/// This is used when there is a call to <see cref="IChatClient.GetResponseAsync"/>. 172/// 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)
9/// <summary>Provides extension methods for working with <see cref="IChatClient"/> in the context of <see cref="ChatClientBuilder"/>.</summary> 20public 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> 64this IChatClient chatClient, 72/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 84this IChatClient chatClient, 92/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 105this IChatClient chatClient, 114/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 127this IChatClient chatClient, 136/// <param name="chatClient">The <see cref="IChatClient"/>.</param> 152this IChatClient chatClient,
ChatCompletion\ConfigureOptionsChatClient.cs (1)
30public ConfigureOptionsChatClient(IChatClient innerClient, Action<ChatOptions> configure)
ChatCompletion\DistributedCachingChatClient.cs (3)
31/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the employed 44/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 46public DistributedCachingChatClient(IChatClient innerClient, IDistributedCache storage)
ChatCompletion\DistributedCachingChatClientBuilderExtensions.cs (1)
13/// Extension methods for adding a <see cref="DistributedCachingChatClient"/> to an <see cref="IChatClient"/> pipeline.
ChatCompletion\FunctionInvokingChatClient.cs (9)
36/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the 71/// <param name="innerClient">The underlying <see cref="IChatClient"/>, or the next instance in a chain of clients.</param> 74public FunctionInvokingChatClient(IChatClient innerClient, ILoggerFactory? loggerFactory = null, IServiceProvider? functionInvocationServices = null) 96/// in the chat history when calling the underlying <see cref="IChatClient"/>. 100/// when calling the underlying <see cref="IChatClient"/>. 112/// Setting the value to <see langword="true"/> can help the underlying <see cref="IChatClient"/> bypass problems on 184/// controlled by <see cref="IncludeDetailedErrors"/>). This allows the <see cref="IChatClient"/> to 238Throw.InvalidOperationException($"The inner {nameof(IChatClient)} returned a null {nameof(ChatResponse)}."); 334Throw.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)
50/// <param name="innerClient">The underlying <see cref="IChatClient"/>.</param> 53public OpenTelemetryChatClient(IChatClient innerClient, ILogger? logger = null, string? sourceName = null)
Microsoft.Extensions.AI.Abstractions (45)
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 (2)
8/// <summary>Provides metadata about an <see cref="IChatClient"/>.</summary> 37/// This value can be <see langword="null"/> if no default model is set on the corresponding <see cref="IChatClient"/>.
ChatCompletion\ChatMessage.cs (1)
12/// <summary>Represents a chat message used by an <see cref="IChatClient" />.</summary>
ChatCompletion\ChatResponse.cs (6)
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 conversation, such that 69/// the input messages supplied to <see cref="IChatClient.GetResponseAsync"/> need only be the additional messages beyond 87/// Some <see cref="IChatClient"/> implementations are capable of storing the state for a conversation, such that 88/// the input messages supplied to <see cref="IChatClient.GetResponseAsync"/> need only be the additional messages beyond
ChatCompletion\ChatResponseUpdate.cs (5)
13/// Represents a single streaming response chunk from an <see cref="IChatClient"/>. 121/// Some <see cref="IChatClient"/> implementations are capable of storing the state for a conversation, such that 122/// the input messages supplied to <see cref="IChatClient.GetStreamingResponseAsync"/> need only be the additional messages beyond 139/// Some <see cref="IChatClient"/> implementations are capable of storing the state for a conversation, such that 140/// 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 51/// <summary>Asks the <see cref="IChatClient"/> for an object of the specified type <paramref name="serviceType"/>.</summary> 57/// 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> 63object? 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 AsIChatClient(
Microsoft.Extensions.AI.AzureAIInference.Tests (18)
AzureAIInferenceChatClientIntegrationTests.cs (1)
8protected override IChatClient? CreateChatClient() =>
AzureAIInferenceChatClientTests.cs (17)
43IChatClient chatClient = client.AsIChatClient(model); 54IChatClient chatClient = client.AsIChatClient("model"); 56Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 59using IChatClient pipeline = chatClient 73Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 128using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 201using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 270using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 318using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 354using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 412using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 509using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 592using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 655using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 774using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 860using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 891private 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)
41/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
Microsoft.Extensions.AI.Evaluation.Integration.Tests (7)
QualityEvaluatorTests.cs (4)
83IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient; 115IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient; 144IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient; 168IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient;
SafetyEvaluatorTests.cs (2)
118IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient; 164IChatClient chatClient = scenarioRun.ChatConfiguration!.ChatClient;
Setup.cs (1)
27IChatClient chatClient = azureClient.GetChatClient(Settings.Current.DeploymentName).AsIChatClient();
Microsoft.Extensions.AI.Evaluation.Quality (2)
ChatConversationEvaluator.cs (2)
199/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 354/// A <see cref="ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
Microsoft.Extensions.AI.Evaluation.Reporting (10)
ReportingConfiguration.cs (6)
33/// Gets a <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 52/// the configured <see cref="IChatClient"/> and the <see cref="ChatOptions"/> that are supplied as part of 106/// A <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the 211IChatClient originalChatClient = chatConfiguration.ChatClient; 227IChatClient chatClient; 264private static IEnumerable<string> GetCachingKeysForChatClient(IChatClient chatClient)
ResponseCachingChatClient.cs (1)
21IChatClient originalChatClient,
ScenarioRun.cs (1)
83/// Gets a <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="IChatClient"/> and the
SimpleChatClient.cs (1)
16internal SimpleChatClient(IChatClient originalChatClient, ChatDetails chatDetails)
Storage\DiskBasedReportingConfiguration.cs (1)
28/// 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.Evaluation.Safety (10)
ContentSafetyChatClient.cs (2)
24private readonly IChatClient? _originalChatClient; 29IChatClient? originalChatClient = null)
ContentSafetyEvaluator.cs (2)
66/// The <see cref="IChatClient"/> that should be used to communicate with the Azure AI Content Safety Service when 90IChatClient contentSafetyServiceChatClient,
ContentSafetyServiceConfigurationExtensions.cs (6)
26/// a new <see cref="IChatClient"/> that can be used both to communicate with the AI model that 53/// Returns an <see cref="IChatClient"/> that can be used to communicate with the Azure AI Content Safety service 62/// The original <see cref="IChatClient"/>, if any. If specified, the returned 63/// <see cref="IChatClient"/> will be a wrapper around <paramref name="originalChatClient"/> that can be used both 71public static IChatClient ToIChatClient( 73IChatClient? originalChatClient = null)
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)
31internal 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> 203object? 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); 172using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient); 265using IChatClient client = new OllamaChatClient("http://localhost:11434", httpClient: httpClient); 369using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient) 460using IChatClient client = new OllamaChatClient("http://localhost:11434", "llama3.1", httpClient)
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (1)
OllamaSharpChatClientIntegrationTests.cs (1)
11protected override IChatClient? CreateChatClient() =>
Microsoft.Extensions.AI.OpenAI (13)
OpenAIChatClient.cs (2)
24/// <summary>Represents an <see cref="IChatClient"/> for an OpenAI <see cref="OpenAIClient"/> or <see cref="ChatClient"/>.</summary> 58object? IChatClient.GetService(Type serviceType, object? serviceKey)
OpenAIClientExtensions.cs (9)
19/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="OpenAIClient"/>.</summary> 22/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="OpenAIClient"/>.</returns> 25public static IChatClient AsChatClient(this OpenAIClient openAIClient, string modelId) => 28/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="ChatClient"/>.</summary> 30/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="ChatClient"/>.</returns> 31public static IChatClient AsIChatClient(this ChatClient chatClient) => 34/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="OpenAIResponseClient"/>.</summary> 36/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="OpenAIResponseClient"/>.</returns> 37public static IChatClient AsIChatClient(this OpenAIResponseClient responseClient) =>
OpenAIResponseChatClient.cs (2)
24/// <summary>Represents an <see cref="IChatClient"/> for an <see cref="OpenAIResponseClient"/>.</summary> 61object? IChatClient.GetService(Type serviceType, object? serviceKey)
Microsoft.Extensions.AI.OpenAI.Tests (31)
OpenAIChatClientIntegrationTests.cs (1)
8protected override IChatClient? CreateChatClient() =>
OpenAIChatClientTests.cs (21)
43IChatClient chatClient = client.GetChatClient(model).AsIChatClient(); 60IChatClient chatClient = openAIClient.AsIChatClient(); 62Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 68using IChatClient pipeline = chatClient 81Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 88IChatClient chatClient = openAIClient.AsIChatClient(); 90Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 93using IChatClient pipeline = chatClient 106Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 156using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 237using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 318using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 407using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 517using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 616using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 739using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 826using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 929using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 1071using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 1194using IChatClient client = CreateChatClient(httpClient, "gpt-4o-mini"); 1239private static IChatClient CreateChatClient(HttpClient httpClient, string modelId) =>
OpenAIResponseClientIntegrationTests.cs (1)
8protected override IChatClient? CreateChatClient() =>
OpenAIResponseClientTests.cs (8)
42IChatClient chatClient = client.GetOpenAIResponseClient(model).AsIChatClient(); 53IChatClient chatClient = openAIClient.AsIChatClient(); 55Assert.Same(chatClient, chatClient.GetService<IChatClient>()); 58using IChatClient pipeline = chatClient 71Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<IChatClient>()); 150using IChatClient client = CreateResponseClient(httpClient, "gpt-4o-mini"); 250using IChatClient client = CreateResponseClient(httpClient, "gpt-4o-mini"); 284private static IChatClient CreateResponseClient(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)
801private sealed class CachingChatClientWithCustomKey(IChatClient innerClient, IDistributedCache storage)
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
843using IChatClient service = innerClient.AsBuilder().UseFunctionInvocation().Build(); 967IChatClient service = configurePipeline(innerClient.AsBuilder()).Build(services); 1061IChatClient 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)