1 type derived from ChatOptions
Microsoft.Extensions.AI.Evaluation.Safety (1)
113 instantiations of ChatOptions
Microsoft.Extensions.AI (2)
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 (2)
Microsoft.Extensions.AI.Evaluation.Quality (9)
Microsoft.Extensions.AI.Integration.Tests (15)
ChatClientIntegrationTests.cs (15)
127var response = _chatClient.GetStreamingResponseAsync("Explain in 10 words how AI works", new()
183new() { ModelId = GetModel_MultiModal_DescribeImage() });
201new() { ModelId = GetModel_MultiModal_DescribeImage() });
228var response = await chatClient.GetResponseAsync(messages, new()
244var response = await chatClient.GetResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
259var response = chatClient.GetStreamingResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
296var response = await chatClient.GetResponseAsync(messages, new()
328var response = await chatClient.GetResponseAsync(messages, new()
369ChatOptions options = new()
412var response = await chatClient.GetResponseAsync("How much older is Elsa than Anna? Return the age difference as a single number.", new()
444var response = await chatClient.GetResponseAsync("Are birds real?", new()
465var response = await chatClient.GetResponseAsync("What's the current secret number?", new()
727new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] });
753new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] }))
905"Who is person with ID 123?", new ChatOptions
Microsoft.Extensions.AI.Ollama.Tests (7)
Microsoft.Extensions.AI.OpenAI.Tests (14)
Microsoft.Extensions.AI.Tests (34)
Microsoft.ML.GenAI.LLaMA (2)
Microsoft.ML.GenAI.Phi (2)
221 references to ChatOptions
Aspire.Azure.AI.OpenAI.Tests (1)
Aspire.OpenAI.Tests (1)
Microsoft.Extensions.AI (67)
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 (7)
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);
200private static bool UseCaching(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 (9)
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
210IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
305IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
529private static void UpdateOptionsForNextIteration(ref ChatOptions options, string? conversationId)
560List<ChatMessage> messages, ChatOptions options, List<FunctionCallContent> functionCallContents, int iteration, int consecutiveErrorCount,
689List<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 (8)
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (2)
Microsoft.Extensions.AI.Evaluation.Quality (9)
Microsoft.Extensions.AI.Evaluation.Reporting (4)
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.Ollama (11)
Microsoft.Extensions.AI.Ollama.Tests (1)
Microsoft.Extensions.AI.OpenAI (8)
Microsoft.Extensions.AI.OpenAI.Tests (5)
Microsoft.Extensions.AI.Tests (39)
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)