1 type derived from ChatOptions
Microsoft.Extensions.AI.Evaluation.Safety (1)
128 instantiations of ChatOptions
Microsoft.Extensions.AI (3)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (7)
Microsoft.Extensions.AI.AzureAIInference.Tests (18)
AzureAIInferenceChatClientTests.cs (18)
45await Assert.ThrowsAsync<InvalidOperationException>(() => chatClient.GetResponseAsync("hello", new ChatOptions { ModelId = null }));
46await Assert.ThrowsAsync<InvalidOperationException>(() => chatClient.GetStreamingResponseAsync("hello", new ChatOptions { ModelId = null }).GetAsyncEnumerator().MoveNextAsync().AsTask());
148var response = await client.GetResponseAsync(messages, new()
222await foreach (var update in client.GetStreamingResponseAsync(messages, new()
254var response = await client.GetResponseAsync("hello", new ChatOptions
272await foreach (var update in client.GetStreamingResponseAsync("hello", new ChatOptions
330ChatOptions chatOptions = new ChatOptions
414ChatOptions chatOptions = new ChatOptions
503ChatOptions chatOptions = new ChatOptions
578ChatOptions chatOptions = new ChatOptions
684Assert.NotNull(await client.GetResponseAsync("hello", new()
743Assert.NotNull(await client.GetResponseAsync("hello", new()
794Assert.NotNull(await client.GetResponseAsync("hello", new()
830Assert.NotNull(await client.GetResponseAsync("hello", new()
887Assert.NotNull(await client.GetResponseAsync("hello", new()
994var response = await client.GetResponseAsync(messages, new()
1249var response = await client.GetResponseAsync("How old is Alice?", new()
1336await foreach (var update in client.GetStreamingResponseAsync("How old is Alice?", new()
Microsoft.Extensions.AI.Evaluation.Integration.Tests (4)
Microsoft.Extensions.AI.Evaluation.Quality (12)
Microsoft.Extensions.AI.Integration.Tests (17)
ChatClientIntegrationTests.cs (17)
134var response = ChatClient.GetStreamingResponseAsync("Explain in 10 words how AI works", new()
190new() { ModelId = GetModel_MultiModal_DescribeImage() });
208new() { ModelId = GetModel_MultiModal_DescribeImage() });
235var response = await chatClient.GetResponseAsync(messages, new()
251var response = await chatClient.GetResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
266var response = chatClient.GetStreamingResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
303var response = await chatClient.GetResponseAsync(messages, new()
335var response = await chatClient.GetResponseAsync(messages, new()
367var response = await chatClient.GetResponseAsync(messages, new()
444ChatOptions options = new()
573var response = await chatClient.GetResponseAsync("How much older is Elsa than Anna? Return the age difference as a single number.", new()
605var response = await chatClient.GetResponseAsync("Are birds real?", new()
626var response = await chatClient.GetResponseAsync("What's the current secret number?", new()
888new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] });
914new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] }))
1066"Who is person with ID 123?", new ChatOptions
1246var response = await chatClient.GetResponseAsync(messages, new() { Tools = [getWeather] });
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (2)
Microsoft.Extensions.AI.OpenAI.Tests (23)
Microsoft.Extensions.AI.Tests (37)
Microsoft.ML.GenAI.LLaMA (2)
Microsoft.ML.GenAI.Phi (2)
252 references to ChatOptions
Aspire.Azure.AI.OpenAI.Tests (1)
Aspire.OpenAI.Tests (1)
Microsoft.Extensions.AI (72)
ChatCompletion\AnonymousDelegatingChatClient.cs (11)
23private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? _getResponseFunc;
31private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc;
34private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task>? _sharedFunc;
53Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task> sharedFunc)
79Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc,
80Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
91IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
100IEnumerable<ChatMessage> messages, ChatOptions? options, CancellationToken cancellationToken)
130IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
ChatCompletion\CachingChatClient.cs (8)
50IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
60IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
78IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
88IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
150/// <param name="options">The <see cref="ChatOptions"/> to inform the key.</param>
153protected abstract string GetCacheKey(IEnumerable<ChatMessage> messages, ChatOptions? options, params ReadOnlySpan<object?> additionalValues);
210/// does not have a <see cref="ChatOptions.ConversationId"/> set.
212protected virtual bool EnableCaching(IEnumerable<ChatMessage> messages, ChatOptions? options)
ChatCompletion\ChatClientBuilder.cs (4)
108public ChatClientBuilder Use(Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task> sharedFunc)
143Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc,
144Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
ChatCompletion\FunctionInvokingChatClient.cs (11)
25/// A delegating chat client that invokes functions defined on <see cref="ChatOptions"/>.
31/// by calling the corresponding <see cref="AIFunction"/> defined in <see cref="ChatOptions.Tools"/>,
38/// <see cref="AIFunction"/> instances employed as part of the supplied <see cref="ChatOptions"/> are also safe.
43/// ASP.NET web request should only be used as part of a single <see cref="ChatOptions"/> at a time, and only with
211/// <see cref="ChatOptions.Tools" /> unmodified. However, if the inner client requests the invocation of a tool
212/// that was not in <see cref="ChatOptions.Tools" />, this <see cref="AdditionalTools"/> collection will also be consulted
229IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
324IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
548private static void UpdateOptionsForNextIteration(ref ChatOptions? options, string? conversationId)
586List<ChatMessage> messages, ChatOptions? options, List<FunctionCallContent> functionCallContents, int iteration, int consecutiveErrorCount,
715List<ChatMessage> messages, ChatOptions? options, List<FunctionCallContent> callContents,
Microsoft.Extensions.AI.Abstractions (23)
Microsoft.Extensions.AI.Abstractions.Tests (15)
TestChatClient.cs (4)
20public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
29public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.AzureAIInference (9)
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (4)
Microsoft.Extensions.AI.Evaluation.Quality (21)
Microsoft.Extensions.AI.Evaluation.Reporting (3)
Microsoft.Extensions.AI.Evaluation.Safety (2)
Microsoft.Extensions.AI.Integration.Tests (12)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (4)
20public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
29public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI (22)
Microsoft.Extensions.AI.OpenAI.Tests (9)
Microsoft.Extensions.AI.Tests (44)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (4)
20public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
29public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.ML.GenAI.Core (3)
Microsoft.ML.GenAI.LLaMA (3)
Microsoft.ML.GenAI.Phi (3)