13 implementations of IChatClient
Microsoft.Extensions.AI.Abstractions (1)
ChatCompletion\DelegatingChatClient.cs (1)
20
public class DelegatingChatClient :
IChatClient
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestChatClient.cs (1)
11
public sealed class TestChatClient :
IChatClient
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
24
internal sealed class AzureAIInferenceChatClient :
IChatClient
Microsoft.Extensions.AI.Evaluation.Safety (1)
ContentSafetyChatClient.cs (1)
17
internal sealed class ContentSafetyChatClient :
IChatClient
Microsoft.Extensions.AI.Integration.Tests (3)
ChatClientIntegrationTests.cs (1)
1358
private sealed class TestSummarizingChatClient :
IChatClient
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (1)
11
public sealed class TestChatClient :
IChatClient
ToolReductionTests.cs (1)
644
private sealed class TestChatClient :
IChatClient
Microsoft.Extensions.AI.OpenAI (3)
OpenAIAssistantsChatClient.cs (1)
24
internal sealed class OpenAIAssistantsChatClient :
IChatClient
OpenAIChatClient.cs (1)
27
internal sealed partial class OpenAIChatClient :
IChatClient
OpenAIResponsesChatClient.cs (1)
28
internal sealed class OpenAIResponsesChatClient :
IChatClient
Microsoft.Extensions.AI.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (1)
11
public sealed class TestChatClient :
IChatClient
Microsoft.Extensions.DataIngestion.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (1)
11
public sealed class TestChatClient :
IChatClient
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
17
public abstract class CausalLMPipelineChatClient<TTokenizer, TCausalLMModel> :
IChatClient
564 references to IChatClient
Aspire.Azure.AI.Inference (5)
AspireAzureAIInferenceExtensions.cs (5)
177
/// Creates a <see cref="
IChatClient
"/> from the <see cref="ChatCompletionsClient"/> registered in the service collection.
191
/// Creates a <see cref="
IChatClient
"/> from the <see cref="ChatCompletionsClient"/> registered in the service collection.
194
/// <param name="serviceKey">The service key with which the <see cref="
IChatClient
"/> will be registered.</param>
208
private static
IChatClient
CreateInnerChatClient(AspireChatCompletionsClientBuilder builder, IServiceProvider services, string? deploymentName)
214
var
result = chatCompletionsClient.AsIChatClient(deploymentName ?? builder.DeploymentName);
Aspire.Azure.AI.Inference.Tests (8)
AspireAzureAIInferenceExtensionTests.cs (6)
107
var
client = useKeyed ?
108
host.Services.GetKeyedService<
IChatClient
>("inference") :
109
host.Services.GetService<
IChatClient
>();
132
var
client = useKeyed ?
133
host.Services.GetKeyedService<
IChatClient
>("inference") :
134
host.Services.GetService<
IChatClient
>();
ConformanceTests.cs (2)
13
public class ConformanceTests : ConformanceTests<
IChatClient
, ChatCompletionsClientSettings>
81
protected override void TriggerActivity(
IChatClient
service)
Aspire.Azure.AI.OpenAI.Tests (25)
AspireAzureOpenAIClientBuilderChatClientExtensionsTests.cs (20)
35
var
client = useKeyed ?
36
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
37
host.Services.GetRequiredService<
IChatClient
>();
65
var
client = useKeyed ?
66
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
67
host.Services.GetRequiredService<
IChatClient
>();
93
var
client = useKeyed ?
94
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
95
host.Services.GetRequiredService<
IChatClient
>();
125
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
126
host.Services.GetRequiredService<
IChatClient
>();
156
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
157
host.Services.GetRequiredService<
IChatClient
>();
186
var
client = useKeyed ?
187
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
188
host.Services.GetRequiredService<
IChatClient
>();
213
var
client = useKeyed ?
214
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
215
host.Services.GetRequiredService<
IChatClient
>();
220
static Task<ChatResponse> TestMiddleware(IEnumerable<ChatMessage> list, ChatOptions? options,
IChatClient
client, CancellationToken token)
AspireConfigurableOpenAIExtensionsTests.cs (3)
243
var
chatClient = useKeyed ?
244
host.Services.GetRequiredKeyedService<
IChatClient
>("chat") :
245
host.Services.GetRequiredService<
IChatClient
>();
ConformanceTests.cs (2)
16
public class ConformanceTests : ConformanceTests<
IChatClient
, AzureOpenAISettings>
105
protected override void TriggerActivity(
IChatClient
service)
Aspire.Dashboard (5)
Model\Assistant\AIHelpers.cs (1)
447
IChatClient
client,
Model\Assistant\AssistantChatViewModel.cs (2)
200
private
IChatClient
_client = null!;
201
private
IChatClient
_followUpClient = null!;
Model\Assistant\ChatClientFactory.cs (2)
45
public
IChatClient
CreateClient(string model)
49
var
innerChatClient = new OpenAI.Chat.ChatClient(
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>
58
private static
IChatClient
CreateInnerChatClient(
68
var
result = openAiClient.GetChatClient(deploymentName).AsIChatClient();
Aspire.OpenAI.Tests (25)
AspireOpenAIClientBuilderChatClientExtensionsTests.cs (23)
38
var
client = useKeyed ?
39
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
40
host.Services.GetRequiredService<
IChatClient
>();
68
var
client = useKeyed ?
69
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
70
host.Services.GetRequiredService<
IChatClient
>();
96
var
client = useKeyed ?
97
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
98
host.Services.GetRequiredService<
IChatClient
>();
128
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
129
host.Services.GetRequiredService<
IChatClient
>();
159
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
160
host.Services.GetRequiredService<
IChatClient
>();
189
var
client = useKeyed ?
190
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
191
host.Services.GetRequiredService<
IChatClient
>();
216
var
client = useKeyed ?
217
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
218
host.Services.GetRequiredService<
IChatClient
>();
249
var
client = useKeyed ?
250
host.Services.GetRequiredKeyedService<
IChatClient
>("openai_chatclient") :
251
host.Services.GetRequiredService<
IChatClient
>();
268
private static Task<ChatResponse> TestMiddleware(IEnumerable<ChatMessage> list, ChatOptions? options,
IChatClient
client, CancellationToken token)
ConformanceTests.cs (2)
14
public class ConformanceTests : ConformanceTests<
IChatClient
, OpenAISettings>
85
protected override void TriggerActivity(
IChatClient
service)
AzureAIFoundryEndToEnd.WebStory (1)
Components_Pages_Home_razor.g.cs (1)
201
IChatClient
AzureOpenAIEndToEnd.WebStory (1)
Components_Pages_Home_razor.g.cs (1)
201
IChatClient
GitHubModelsEndToEnd.WebStory (1)
Components_Pages_Home_razor.g.cs (1)
201
IChatClient
Microsoft.Extensions.AI (107)
ChatCompletion\AnonymousDelegatingChatClient.cs (6)
21
private readonly Func<IEnumerable<ChatMessage>, ChatOptions?,
IChatClient
, CancellationToken, Task<ChatResponse>>? _getResponseFunc;
29
private readonly Func<IEnumerable<ChatMessage>, ChatOptions?,
IChatClient
, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc;
50
IChatClient
innerClient,
76
IChatClient
innerClient,
77
Func<IEnumerable<ChatMessage>, ChatOptions?,
IChatClient
, CancellationToken, Task<ChatResponse>>? getResponseFunc,
78
Func<IEnumerable<ChatMessage>, ChatOptions?,
IChatClient
, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
ChatCompletion\CachingChatClient.cs (7)
25
/// <param name="innerClient">The underlying <see cref="
IChatClient
"/>.</param>
26
protected CachingChatClient(
IChatClient
innerClient)
154
/// This is used when there is a call to <see cref="
IChatClient
.GetResponseAsync"/>.
164
/// This is used when there is a call to <see cref="
IChatClient
.GetStreamingResponseAsync"/>.
174
/// This is used when there is a call to <see cref="
IChatClient
.GetResponseAsync"/>.
186
/// This is used when there is a call to <see cref="
IChatClient
.GetStreamingResponseAsync"/>.
203
/// be passed through to the inner <see cref="
IChatClient
"/> without attempting to read from or write to the cache.
ChatCompletion\ChatClientBuilder.cs (34)
12
/// <summary>A builder for creating pipelines of <see cref="
IChatClient
"/>.</summary>
15
private readonly Func<IServiceProvider,
IChatClient
> _innerClientFactory;
18
private List<Func<
IChatClient
, IServiceProvider,
IChatClient
>>? _clientFactories;
21
/// <param name="innerClient">The inner <see cref="
IChatClient
"/> that represents the underlying backend.</param>
23
public ChatClientBuilder(
IChatClient
innerClient)
30
/// <param name="innerClientFactory">A callback that produces the inner <see cref="
IChatClient
"/> that represents the underlying backend.</param>
31
public 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>
42
public
IChatClient
Build(IServiceProvider? services = null)
45
var
chatClient = _innerClientFactory(services);
57
$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(
IChatClient
)} instances.");
70
public ChatClientBuilder Use(Func<
IChatClient
,
IChatClient
> clientFactory)
82
public ChatClientBuilder Use(Func<
IChatClient
, IServiceProvider,
IChatClient
> clientFactory)
92
/// an implementation for both <see cref="
IChatClient
.GetResponseAsync"/> and <see cref="
IChatClient
.GetStreamingResponseAsync"/>.
95
/// A delegate that provides the implementation for both <see cref="
IChatClient
.GetResponseAsync"/> and
96
/// <see cref="
IChatClient
.GetStreamingResponseAsync"/>. This delegate is invoked with the list of chat messages, the chat
117
/// an implementation for both <see cref="
IChatClient
.GetResponseAsync"/> and <see cref="
IChatClient
.GetStreamingResponseAsync"/>.
120
/// A delegate that provides the implementation for <see cref="
IChatClient
.GetResponseAsync"/>. When <see langword="null"/>,
121
/// <paramref name="getStreamingResponseFunc"/> must be non-null, and the implementation of <see cref="
IChatClient
.GetResponseAsync"/>
125
/// A delegate that provides the implementation for <see cref="
IChatClient
.GetStreamingResponseAsync"/>. When <see langword="null"/>,
126
/// <paramref name="getResponseFunc"/> must be non-null, and the implementation of <see cref="
IChatClient
.GetStreamingResponseAsync"/>
132
/// <paramref name="getResponseFunc"/> will provide the implementation of <see cref="
IChatClient
.GetResponseAsync"/>, and
133
/// <paramref name="getStreamingResponseFunc"/> will provide the implementation of <see cref="
IChatClient
.GetStreamingResponseAsync"/>.
135
/// is supplied without <paramref name="getStreamingResponseFunc"/>, the implementation of <see cref="
IChatClient
.GetStreamingResponseAsync"/>
138
/// <see cref="
IChatClient
.GetResponseAsync"/> will be implemented by combining the updates from <paramref name="getStreamingResponseFunc"/>.
143
Func<IEnumerable<ChatMessage>, ChatOptions?,
IChatClient
, CancellationToken, Task<ChatResponse>>? getResponseFunc,
144
Func<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>
20
public 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>
23
IChatClient
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>
42
Func<IServiceProvider,
IChatClient
> innerClientFactory,
49
serviceCollection.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>
65
IChatClient
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>
86
Func<IServiceProvider,
IChatClient
> innerClientFactory,
93
serviceCollection.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.
25
/// <param name="chatClient">The <see cref="
IChatClient
"/>.</param>
36
this
IChatClient
chatClient,
44
/// <param name="chatClient">The <see cref="
IChatClient
"/>.</param>
56
this
IChatClient
chatClient,
64
/// <param name="chatClient">The <see cref="
IChatClient
"/>.</param>
75
this
IChatClient
chatClient,
83
/// <param name="chatClient">The <see cref="
IChatClient
"/>.</param>
95
this
IChatClient
chatClient,
104
/// <param name="chatClient">The <see cref="
IChatClient
"/>.</param>
116
this
IChatClient
chatClient,
125
/// <param name="chatClient">The <see cref="
IChatClient
"/>.</param>
138
this
IChatClient
chatClient,
ChatCompletion\ConfigureOptionsChatClient.cs (1)
30
public 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
48
/// <param name="innerClient">The underlying <see cref="
IChatClient
"/>.</param>
50
public 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\FunctionInvocationContext.cs (3)
84
/// If multiple function call requests are issued as part of a single iteration (a single response from the inner <see cref="
IChatClient
"/>),
92
/// <see cref="
IChatClient
.GetStreamingResponseAsync"/> call as opposed to a <see cref="
IChatClient
.GetResponseAsync"/> call.
ChatCompletion\FunctionInvokingChatClient.cs (11)
29
/// <see cref="
IChatClient
"/>, it responds by invoking the corresponding <see cref="AIFunction"/> defined
48
/// Due to the nature of interactions with an underlying <see cref="
IChatClient
"/>, if any <see cref="FunctionCallContent"/> is received
83
/// <param name="innerClient">The underlying <see cref="
IChatClient
"/>, or the next instance in a chain of clients.</param>
86
public FunctionInvokingChatClient(
IChatClient
innerClient, ILoggerFactory? loggerFactory = null, IServiceProvider? functionInvocationServices = null)
108
/// in the chat history when calling the underlying <see cref="
IChatClient
"/>.
112
/// when calling the underlying <see cref="
IChatClient
"/>.
124
/// Setting the value to <see langword="true"/> can help the underlying <see cref="
IChatClient
"/> bypass problems on
196
/// controlled by <see cref="IncludeDetailedErrors"/>). This allows the <see cref="
IChatClient
"/> to
324
Throw.InvalidOperationException($"The inner {nameof(
IChatClient
)} returned a null {nameof(ChatResponse)}.");
494
Throw.InvalidOperationException($"The inner {nameof(
IChatClient
)} streamed a null {nameof(ChatResponseUpdate)}.");
1467
/// using the same message id that the <see cref="FunctionCallContent"/> was originally returned with from the downstream <see cref="
IChatClient
"/>.
ChatCompletion\LoggingChatClient.cs (3)
18
/// The provided implementation of <see cref="
IChatClient
"/> is thread-safe for concurrent use so long as the
37
/// <param name="innerClient">The underlying <see cref="
IChatClient
"/>.</param>
39
public LoggingChatClient(
IChatClient
innerClient, ILogger logger)
ChatCompletion\OpenTelemetryChatClient.cs (2)
47
/// <param name="innerClient">The underlying <see cref="
IChatClient
"/>.</param>
51
public OpenTelemetryChatClient(
IChatClient
innerClient, ILogger? logger = null, string? sourceName = null)
ChatCompletion\ReducingChatClient.cs (2)
22
/// <param name="innerClient">The underlying <see cref="
IChatClient
"/>, or the next instance in a chain of clients.</param>
24
public ReducingChatClient(
IChatClient
innerClient, IChatReducer reducer)
ChatReduction\SummarizingChatReducer.cs (3)
45
private readonly
IChatClient
_chatClient;
65
public SummarizingChatReducer(
IChatClient
chatClient, int targetCount, int? threshold)
123
IChatClient
chatClient, int indexOfFirstMessageToKeep, string summarizationPrompt, CancellationToken cancellationToken)
ToolReduction\ToolReducingChatClient.cs (1)
33
public ToolReducingChatClient(
IChatClient
innerClient, IToolReductionStrategy strategy)
Microsoft.Extensions.AI.Abstractions (62)
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
"/>,
25
public 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
"/>,
47
public 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
"/>,
71
public static TService GetRequiredService<TService>(this
IChatClient
client, object? serviceKey = null)
92
this
IChatClient
client,
112
this
IChatClient
client,
132
this
IChatClient
client,
152
this
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\ChatOptions.cs (12)
61
/// <summary>Gets or sets additional per-request instructions to be provided to the <see cref="
IChatClient
"/>.</summary>
139
/// <see langword="true"/> for no limit. <see langword="false"/> if the <see cref="
IChatClient
"/> is asked to return a maximum of one tool call per request. If <see langword="null"/>, the provider can select its own default.
190
/// property if the <see cref="
IChatClient
"/> implementation supports them.
191
/// Streamed background responses, such as those returned by default by <see cref="
IChatClient
.GetStreamingResponseAsync"/>,
194
/// Non-streamed background responses, such as those returned by <see cref="
IChatClient
.GetResponseAsync"/>,
196
/// and passing it to this property on subsequent calls to <see cref="
IChatClient
.GetResponseAsync"/>.
206
/// The underlying <see cref="
IChatClient
" /> implementation might have its own representation of options.
207
/// When <see cref="
IChatClient
.GetResponseAsync" /> or <see cref="
IChatClient
.GetStreamingResponseAsync" />
210
/// which concrete <see cref="
IChatClient
" /> is being used and how it represents options, a new instance of that
211
/// implementation-specific options type can be returned by this callback for the <see cref="
IChatClient
" />
220
public Func<
IChatClient
, object?>? RawRepresentationFactory { get; set; }
ChatCompletion\ChatResponse.cs (6)
17
/// request to a <see cref="
IChatClient
"/> might actually generate multiple round-trips 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
92
/// <see cref="
IChatClient
"/> implementations that support background responses will return
99
/// <see cref="ChatOptions.ContinuationToken"/> on subsequent calls to <see cref="
IChatClient
.GetResponseAsync"/>
ChatCompletion\ChatResponseUpdate.cs (5)
13
/// Represents a single streaming response chunk from an <see cref="
IChatClient
"/>.
118
/// Some <see cref="
IChatClient
"/> implementations are capable of storing the state for a conversation, such that
119
/// the input messages supplied to <see cref="
IChatClient
.GetStreamingResponseAsync"/> need only be the additional messages beyond
141
/// <see cref="
IChatClient
"/> implementations that support background responses return
146
/// passed to <see cref="ChatOptions.ContinuationToken"/> on subsequent calls to <see cref="
IChatClient
.GetStreamingResponseAsync"/>
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
"/>.
27
protected DelegatingChatClient(
IChatClient
innerClient)
39
/// <summary>Gets the inner <see cref="
IChatClient
" />.</summary>
40
protected
IChatClient
InnerClient { get; }
ChatCompletion\IChatClient.cs (7)
15
/// sent to the underlying provider or returned from it. Unless a specific <see cref="
IChatClient
"/> implementation
19
/// Unless otherwise specified, all members of <see cref="
IChatClient
"/> are thread-safe for concurrent use.
20
/// It is expected that all implementations of <see cref="
IChatClient
"/> support being used by multiple requests concurrently.
24
/// However, implementations of <see cref="
IChatClient
"/> might mutate the arguments supplied to <see cref="GetResponseAsync"/> and
27
/// that no <see cref="
IChatClient
"/> instances are used which might employ such mutation. For example, the ConfigureOptions method is
59
/// <summary>Asks the <see cref="
IChatClient
"/> for an object of the specified type <paramref name="serviceType"/>.</summary>
65
/// 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.
ToolReduction\IToolReductionStrategy.cs (1)
15
/// A tool reduction strategy is invoked prior to sending a request to an underlying <see cref="
IChatClient
"/>,
Tools\HostedCodeInterpreterTool.cs (1)
27
/// Unsupported inputs will be ignored by the <see cref="
IChatClient
"/> to which the tool is passed.
Utilities\AIJsonSchemaTransformCache.cs (2)
17
/// to their corresponding JSON schemas transformed according to the specified <see cref="TransformOptions"/> policy. It is intended for use by <see cref="
IChatClient
"/>
21
/// It is recommended <see cref="
IChatClient
"/> implementations with schema transformation requirements create a single static instance of this cache.
Microsoft.Extensions.AI.Abstractions.Tests (7)
ChatCompletion\ChatClientExtensionsTests.cs (3)
42
if (serviceType == typeof(
IChatClient
))
57
Assert.Null(client.GetService<
IChatClient
>());
69
Assert.Throws<InvalidOperationException>(() => client.GetRequiredService<
IChatClient
>());
ChatCompletion\ChatOptionsTests.cs (1)
79
Func<
IChatClient
, object?> rawRepresentationFactory = (c) => null;
ChatCompletion\DelegatingChatClientTests.cs (3)
126
var
client = delegating.GetService<
IChatClient
>(expectedKey);
163
private sealed class NoOpDelegatingChatClient(
IChatClient
innerClient)
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (2)
23
/// <summary>Represents an <see cref="
IChatClient
"/> for an Azure AI Inference <see cref="ChatCompletionsClient"/>.</summary>
71
object?
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>
15
public static
IChatClient
AsIChatClient(
Microsoft.Extensions.AI.AzureAIInference.Tests (26)
AzureAIInferenceChatClientIntegrationTests.cs (1)
8
protected override
IChatClient
? CreateChatClient() =>
AzureAIInferenceChatClientTests.cs (25)
40
IChatClient
chatClient = client.AsIChatClient(modelId: null);
57
IChatClient
chatClient = client.AsIChatClient(model);
68
IChatClient
chatClient = client.AsIChatClient("model");
70
Assert.Same(chatClient, chatClient.GetService<
IChatClient
>());
73
using
IChatClient
pipeline = chatClient
87
Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<
IChatClient
>());
142
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
215
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
252
using
IChatClient
client = CreateChatClient(httpClient, modelId: null!);
269
using
IChatClient
client = CreateChatClient(httpClient, modelId: null!);
327
using
IChatClient
client = CreateChatClient(httpClient, modelId: null!);
411
using
IChatClient
client = CreateChatClient(httpClient, modelId: null!);
500
using
IChatClient
client = CreateChatClient(httpClient, modelId: null!);
575
using
IChatClient
client = CreateChatClient(httpClient, modelId: null!);
682
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
741
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
792
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
828
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
885
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
982
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1065
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1128
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1247
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1333
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1364
private static
IChatClient
CreateChatClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Evaluation (14)
ChatConfiguration.cs (5)
7
/// Specifies the <see cref="
IChatClient
"/> that should be used when evaluation is performed using an AI model.
9
/// <param name="chatClient">An <see cref="
IChatClient
"/> that can be used to communicate with an AI model.</param>
10
public sealed class ChatConfiguration(
IChatClient
chatClient)
13
/// Gets an <see cref="
IChatClient
"/> that can be used to communicate with an AI model.
15
public
IChatClient
ChatClient { get; } = chatClient;
CompositeEvaluator.cs (1)
89
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
EvaluatorExtensions.cs (6)
33
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
76
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
118
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
158
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
206
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
251
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
IEvaluator.cs (1)
43
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that should be used if one or
Utilities\ModelInfo.cs (1)
74
/// The <see cref="ChatClientMetadata"/> for the <see cref="
IChatClient
"/> that was used to communicate with the
Microsoft.Extensions.AI.Evaluation.Console (1)
src\Libraries\Microsoft.Extensions.AI.Evaluation\Utilities\ModelInfo.cs (1)
74
/// The <see cref="ChatClientMetadata"/> for the <see cref="
IChatClient
"/> that was used to communicate with the
Microsoft.Extensions.AI.Evaluation.Integration.Tests (12)
AgentQualityEvaluatorTests.cs (4)
49
IChatClient
chatClient = chatConfiguration.ChatClient;
50
IChatClient
chatClientWithToolCalling = chatClient.AsBuilder().UseFunctionInvocation().Build();
205
GetConversationWithoutToolsAsync(
IChatClient
chatClient)
218
GetConversationWithToolsAsync(
IChatClient
chatClient)
QualityEvaluatorTests.cs (4)
86
IChatClient
chatClient = scenarioRun.ChatConfiguration!.ChatClient;
127
IChatClient
chatClient = scenarioRun.ChatConfiguration!.ChatClient;
165
IChatClient
chatClient = scenarioRun.ChatConfiguration!.ChatClient;
200
IChatClient
chatClient = scenarioRun.ChatConfiguration!.ChatClient;
SafetyEvaluatorTests.cs (3)
183
IChatClient
chatClient = scenarioRun.ChatConfiguration!.ChatClient;
261
IChatClient
chatClient = scenarioRun.ChatConfiguration!.ChatClient;
588
IChatClient
chatClient = scenarioRun.ChatConfiguration!.ChatClient;
Setup.cs (1)
20
IChatClient
chatClient = openAIClient.AsIChatClient();
Microsoft.Extensions.AI.Evaluation.Reporting (13)
ChatTurnDetails.cs (2)
34
/// for the <see cref="
IChatClient
"/>.
110
/// <see cref="
IChatClient
"/>.
ReportingConfiguration.cs (6)
36
/// Gets a <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that is used by
54
/// the configured <see cref="
IChatClient
"/> and the <see cref="ChatOptions"/> that are supplied as part of
108
/// A <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that is used by
212
IChatClient
originalChatClient = chatConfiguration.ChatClient;
228
IChatClient
chatClient;
265
private static IEnumerable<string> GetCachingKeysForChatClient(
IChatClient
chatClient)
ResponseCachingChatClient.cs (1)
21
IChatClient
originalChatClient,
ScenarioRun.cs (1)
89
/// Gets a <see cref="Evaluation.ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that is used by
SimpleChatClient.cs (1)
18
internal SimpleChatClient(
IChatClient
originalChatClient, ChatDetails chatDetails)
src\Libraries\Microsoft.Extensions.AI.Evaluation\Utilities\ModelInfo.cs (1)
74
/// The <see cref="ChatClientMetadata"/> for the <see cref="
IChatClient
"/> that was used to communicate with the
Storage\DiskBasedReportingConfiguration.cs (1)
28
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that is used by AI-based
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (1)
Storage\AzureStorageReportingConfiguration.cs (1)
28
/// A <see cref="ChatConfiguration"/> that specifies the <see cref="
IChatClient
"/> that is used by AI-based
Microsoft.Extensions.AI.Evaluation.Safety (10)
ContentSafetyChatClient.cs (3)
20
private readonly
IChatClient
? _originalChatClient;
25
IChatClient
? originalChatClient = null)
169
Failed to invoke '{nameof(
IChatClient
)}.{callerMemberName}()'.
ContentSafetyEvaluator.cs (2)
58
/// The <see cref="
IChatClient
"/> that should be used to communicate with the Azure AI Foundry Evaluation Service
82
IChatClient
contentSafetyServiceChatClient,
ContentSafetyServiceConfigurationExtensions.cs (3)
26
/// a new <see cref="
IChatClient
"/> that can be used both to communicate with the AI model that
62
/// The original <see cref="
IChatClient
"/>. The returned <see cref="ChatConfiguration.ChatClient"/> will be a
73
IChatClient
originalChatClient)
ProtectedMaterialEvaluator.cs (1)
76
IChatClient
chatClient = chatConfiguration.ChatClient;
src\Libraries\Microsoft.Extensions.AI.Evaluation\Utilities\ModelInfo.cs (1)
74
/// The <see cref="ChatClientMetadata"/> for the <see cref="
IChatClient
"/> that was used to communicate with the
Microsoft.Extensions.AI.Integration.Tests (25)
CallCountingChatClient.cs (1)
13
internal sealed class CallCountingChatClient(
IChatClient
innerClient) : DelegatingChatClient(innerClient)
ChatClientIntegrationTests.cs (19)
42
protected
IChatClient
? ChatClient { get; }
52
protected abstract
IChatClient
? CreateChatClient();
733
using
var
chatClient = CreateChatClient()!
772
using
var
chatClient = CreateChatClient()!
814
using
var
chatClient = CreateChatClient()!
847
using
var
chatClient = CreateChatClient()!.AsBuilder()
866
using
var
chatClient = CreateChatClient()!.AsBuilder()
888
using
var
chatClient = CreateChatClient()!
914
using
var
chatClient = CreateChatClient()!
946
var
chatClient = CreateChatClient()!.AsBuilder()
1097
var
captureOutputChatClient = ChatClient.AsBuilder()
1240
var
chatClient = ChatClient
1360
private
IChatClient
_summarizerChatClient;
1361
private
IChatClient
_innerChatClient;
1369
public TestSummarizingChatClient(
IChatClient
innerClient, int targetCount, int threshold)
1446
using
var
client = ChatClient!
1521
using
var
client = ChatClient!
1576
using
var
client = ChatClient!
1691
using
var
client = ChatClient!
PromptBasedFunctionCallingChatClient.cs (1)
31
internal sealed class PromptBasedFunctionCallingChatClient(
IChatClient
innerClient)
ReducingChatClientTests.cs (2)
18
/// <summary>Provides an example of a custom <see cref="
IChatClient
"/> for reducing chat message lists.</summary>
38
using
var
client = innerClient
ToolReductionTests.cs (2)
378
using
var
client = inner.AsBuilder().UseToolReduction(strategy).Build();
408
using
var
client = inner.AsBuilder().UseToolReduction(strategy).Build();
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (4)
OllamaSharpChatClientIntegrationTests.cs (4)
17
protected override
IChatClient
? CreateChatClient() =>
35
using
var
chatClient = CreateChatClient()!
59
using
var
chatClient = CreateChatClient()!
107
private sealed class AssertNoToolsDefinedChatClient(
IChatClient
innerClient) : DelegatingChatClient(innerClient)
Microsoft.Extensions.AI.OpenAI (29)
MicrosoftExtensionsAIResponsesExtensions.cs (6)
114
/// The <see cref="
IChatClient
"/> returned by <see cref="OpenAIClientExtensions.AsIChatClient(OpenAIResponseClient)"/> will
129
/// The returned tool is only suitable for use with the <see cref="
IChatClient
"/> returned by
130
/// <see cref="OpenAIClientExtensions.AsIChatClient(OpenAIResponseClient)"/> (or <see cref="
IChatClient
"/>s that delegate
131
/// to such an instance). It is likely to be ignored by any other <see cref="
IChatClient
"/> implementation.
137
/// capable of being respected by any <see cref="
IChatClient
"/> implementation. This method does not attempt to
139
/// the <see cref="
IChatClient
"/> returned by <see cref="OpenAIClientExtensions.AsIChatClient(OpenAIResponseClient)"/> will
OpenAIAssistantsChatClient.cs (1)
23
/// <summary>Represents an <see cref="
IChatClient
"/> for an OpenAI <see cref="AssistantClient"/>.</summary>
OpenAIChatClient.cs (2)
26
/// <summary>Represents an <see cref="
IChatClient
"/> for an OpenAI <see cref="OpenAIClient"/> or <see cref="ChatClient"/>.</summary>
67
object?
IChatClient
.GetService(Type serviceType, object? serviceKey)
OpenAIClientExtensions.cs (18)
107
/// <summary>Gets an <see cref="
IChatClient
"/> for use with this <see cref="ChatClient"/>.</summary>
109
/// <returns>An <see cref="
IChatClient
"/> that can be used to converse via the <see cref="ChatClient"/>.</returns>
111
public static
IChatClient
AsIChatClient(this ChatClient chatClient) =>
114
/// <summary>Gets an <see cref="
IChatClient
"/> for use with this <see cref="OpenAIResponseClient"/>.</summary>
116
/// <returns>An <see cref="
IChatClient
"/> that can be used to converse via the <see cref="OpenAIResponseClient"/>.</returns>
118
public static
IChatClient
AsIChatClient(this OpenAIResponseClient responseClient) =>
121
/// <summary>Gets an <see cref="
IChatClient
"/> for use with this <see cref="AssistantClient"/>.</summary>
122
/// <param name="assistantClient">The <see cref="AssistantClient"/> instance to be accessed as an <see cref="
IChatClient
"/>.</param>
126
/// <see cref="
IChatClient
.GetResponseAsync"/> or <see cref="
IChatClient
.GetStreamingResponseAsync"/> via the <see cref="ChatOptions.ConversationId"/>
129
/// <returns>An <see cref="
IChatClient
"/> instance configured to interact with the specified agent and thread.</returns>
133
public static
IChatClient
AsIChatClient(this AssistantClient assistantClient, string assistantId, string? threadId = null) =>
136
/// <summary>Gets an <see cref="
IChatClient
"/> for use with this <see cref="AssistantClient"/>.</summary>
137
/// <param name="assistantClient">The <see cref="AssistantClient"/> instance to be accessed as an <see cref="
IChatClient
"/>.</param>
141
/// <see cref="
IChatClient
.GetResponseAsync"/> or <see cref="
IChatClient
.GetStreamingResponseAsync"/> via the <see cref="ChatOptions.ConversationId"/>
144
/// <returns>An <see cref="
IChatClient
"/> instance configured to interact with the specified agent and thread.</returns>
147
public static
IChatClient
AsIChatClient(this AssistantClient assistantClient, Assistant assistant, string? threadId = null) =>
OpenAIResponsesChatClient.cs (2)
27
/// <summary>Represents an <see cref="
IChatClient
"/> for an <see cref="OpenAIResponseClient"/>.</summary>
88
object?
IChatClient
.GetService(Type serviceType, object? serviceKey)
Microsoft.Extensions.AI.OpenAI.Tests (103)
OpenAIAssistantChatClientIntegrationTests.cs (1)
23
protected override
IChatClient
? CreateChatClient()
OpenAIAssistantChatClientTests.cs (5)
33
IChatClient
[] clients =
39
foreach (
var
chatClient in clients)
51
IChatClient
chatClient = assistantClient.AsIChatClient("assistantId");
57
using
IChatClient
pipeline = chatClient
70
Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<
IChatClient
>());
OpenAIChatClientIntegrationTests.cs (1)
8
protected override
IChatClient
? CreateChatClient() =>
OpenAIChatClientTests.cs (29)
38
IChatClient
chatClient = client.GetChatClient(model).AsIChatClient();
55
IChatClient
chatClient = openAIClient.AsIChatClient();
57
Assert.Same(chatClient, chatClient.GetService<
IChatClient
>());
63
using
IChatClient
pipeline = chatClient
76
Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<
IChatClient
>());
83
IChatClient
chatClient = openAIClient.AsIChatClient();
85
Assert.Same(chatClient, chatClient.GetService<
IChatClient
>());
88
using
IChatClient
pipeline = chatClient
101
Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<
IChatClient
>());
151
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
230
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
328
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
381
using
IChatClient
client = CreateChatClient(httpClient, modelId: "gpt-4o-mini");
458
using
IChatClient
client = CreateChatClient(httpClient, modelId: "gpt-4o-mini");
541
using
IChatClient
client = CreateChatClient(httpClient, modelId: "gpt-4o-mini");
615
using
IChatClient
client = CreateChatClient(httpClient, modelId: "gpt-4o-mini");
724
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
815
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
922
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1018
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1137
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1221
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1320
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1460
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1580
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1627
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1675
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1721
using
IChatClient
client = CreateChatClient(httpClient, "gpt-4o-mini");
1738
private static
IChatClient
CreateChatClient(HttpClient httpClient, string modelId) =>
OpenAIResponseClientIntegrationTests.cs (4)
15
protected override
IChatClient
? CreateChatClient() =>
136
using
var
client = CreateChatClient()!;
176
using
var
client = CreateChatClient()!;
399
using
var
client = CreateChatClient()!;
OpenAIResponseClientTests.cs (63)
42
IChatClient
chatClient = client.GetOpenAIResponseClient(model).AsIChatClient();
53
IChatClient
chatClient = openAIClient.AsIChatClient();
55
Assert.Same(chatClient, chatClient.GetService<
IChatClient
>());
58
using
IChatClient
pipeline = chatClient
71
Assert.IsType<FunctionInvokingChatClient>(pipeline.GetService<
IChatClient
>());
150
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
293
using
IChatClient
client = CreateResponseClient(httpClient, "o4-mini");
430
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
531
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
676
using
IChatClient
client = CreateResponseClient(httpClient, modelId: "gpt-4o-mini");
804
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
940
using (
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini"))
1062
using (
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini"))
1308
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
1724
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
1837
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
1926
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
1978
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
2073
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-2024-08-06");
2154
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-2024-08-06");
2221
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-2024-08-06");
2346
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-2024-08-06");
2566
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-2024-08-06");
2603
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
2655
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
2713
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
2772
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
2833
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
2895
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
2958
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3031
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3112
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3193
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3271
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3337
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3403
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3473
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3532
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3588
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3649
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3707
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3764
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3823
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3885
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3941
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
3996
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4053
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4110
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4147
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4179
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4223
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4272
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4316
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4351
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4386
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4421
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4459
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4497
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4517
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4555
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4591
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4632
using
IChatClient
client = CreateResponseClient(httpClient, "gpt-4o-mini");
4643
private static
IChatClient
CreateResponseClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Tests (63)
ChatCompletion\ChatClientBuilderTest.cs (5)
61
Assert.Throws<ArgumentNullException>("innerClient", () => new ChatClientBuilder((
IChatClient
)null!));
62
Assert.Throws<ArgumentNullException>("innerClient", () => ((
IChatClient
)null!).AsBuilder());
68
Assert.Throws<ArgumentNullException>("innerClientFactory", () => new ChatClientBuilder((Func<IServiceProvider,
IChatClient
>)null!));
99
private sealed class InnerClientCapturingChatClient(string name,
IChatClient
innerClient) : DelegatingChatClient(innerClient)
104
public new
IChatClient
InnerClient => base.InnerClient;
ChatCompletion\ConfigureOptionsChatClientTests.cs (2)
41
using
IChatClient
innerClient = new TestChatClient
58
using
var
client = innerClient
ChatCompletion\DependencyInjectionPatterns.cs (30)
26
var
instance1 = scope1.ServiceProvider.GetRequiredService<
IChatClient
>();
27
var
instance1Copy = scope1.ServiceProvider.GetRequiredService<
IChatClient
>();
28
var
instance2 = scope2.ServiceProvider.GetRequiredService<
IChatClient
>();
50
var
instance1 = scope1.ServiceProvider.GetRequiredService<
IChatClient
>();
51
var
instance1Copy = scope1.ServiceProvider.GetRequiredService<
IChatClient
>();
52
var
instance2 = scope2.ServiceProvider.GetRequiredService<
IChatClient
>();
73
Assert.Null(services.GetService<
IChatClient
>());
75
var
instance1 = scope1.ServiceProvider.GetRequiredKeyedService<
IChatClient
>("mykey");
76
var
instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<
IChatClient
>("mykey");
77
var
instance2 = scope2.ServiceProvider.GetRequiredKeyedService<
IChatClient
>("mykey");
99
Assert.Null(services.GetService<
IChatClient
>());
101
var
instance1 = scope1.ServiceProvider.GetRequiredKeyedService<
IChatClient
>("mykey");
102
var
instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<
IChatClient
>("mykey");
103
var
instance2 = scope2.ServiceProvider.GetRequiredKeyedService<
IChatClient
>("mykey");
126
Assert.Equal(typeof(
IChatClient
), sd.ServiceType);
148
Assert.Equal(typeof(
IChatClient
), sd.ServiceType);
248
public class SingletonMiddleware(
IChatClient
inner, IServiceProvider services) : DelegatingChatClient(inner)
250
public new
IChatClient
InnerClient => base.InnerClient;
ChatCompletion\DistributedCachingChatClientTest.cs (2)
122
private sealed class CustomCachingChatClient(
IChatClient
innerClient, IDistributedCache storage, Func<IEnumerable<ChatMessage>, ChatOptions?, bool> enableCaching) :
877
private sealed class CachingChatClientWithCustomKey(
IChatClient
innerClient, IDistributedCache storage)
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (4)
718
IChatClient
service = configurePipeline(innerClient.AsBuilder()).Build();
796
IChatClient
service = configurePipeline(innerClient.AsBuilder()).Build();
901
IChatClient
service = configurePipeline(innerClient.AsBuilder()).Build();
983
IChatClient
service = configurePipeline(innerClient.AsBuilder()).Build();
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
1004
using
IChatClient
service = innerClient.AsBuilder().UseFunctionInvocation().Build();
1281
IChatClient
service = configurePipeline(innerClient.AsBuilder()).Build(services);
1345
IChatClient
service = configurePipeline(innerClient.AsBuilder()).Build(services);
ChatCompletion\LoggingChatClientTests.cs (5)
30
Assert.Same(innerClient, innerClient.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(
IChatClient
)));
55
using
IChatClient
innerClient = new TestChatClient
63
using
IChatClient
client = innerClient
100
using
IChatClient
innerClient = new TestChatClient
112
using
IChatClient
client = innerClient
ChatCompletion\ReducingChatClientTests.cs (2)
113
using
var
client = innerClient
150
using
var
client = innerClient
ChatCompletion\UseDelegateChatClientTests.cs (10)
34
using
IChatClient
innerClient = new TestChatClient
55
using
IChatClient
client = new ChatClientBuilder(innerClient)
83
using
IChatClient
innerClient = new TestChatClient
95
using
IChatClient
client = new ChatClientBuilder(innerClient)
125
using
IChatClient
innerClient = new TestChatClient
137
using
IChatClient
client = new ChatClientBuilder(innerClient)
147
IEnumerable<ChatMessage> messages, ChatOptions? options,
IChatClient
innerClient, [EnumeratorCancellation] CancellationToken cancellationToken)
176
using
IChatClient
innerClient = new TestChatClient
197
using
IChatClient
client = new ChatClientBuilder(innerClient)
218
IEnumerable<ChatMessage> messages, ChatOptions? options,
IChatClient
innerClient, [EnumeratorCancellation] CancellationToken cancellationToken)
Microsoft.Extensions.DataIngestion (2)
Processors\EnricherOptions.cs (2)
19
public EnricherOptions(
IChatClient
chatClient)
27
public
IChatClient
ChatClient { get; }
OpenAIEndToEnd.WebStory (1)
Components_Pages_Home_razor.g.cs (1)
201
IChatClient