1 type derived from ChatOptions
Microsoft.Extensions.AI.Evaluation.Safety (1)
118 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 (4)
Microsoft.Extensions.AI.Evaluation.Quality (12)
Microsoft.Extensions.AI.Integration.Tests (15)
ChatClientIntegrationTests.cs (15)
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()
411ChatOptions options = new()
540var response = await chatClient.GetResponseAsync("How much older is Elsa than Anna? Return the age difference as a single number.", new()
572var response = await chatClient.GetResponseAsync("Are birds real?", new()
593var response = await chatClient.GetResponseAsync("What's the current secret number?", new()
855new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] });
881new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] }))
1033"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)
245 references to ChatOptions
Aspire.Azure.AI.OpenAI.Tests (1)
Aspire.OpenAI.Tests (1)
Microsoft.Extensions.AI (68)
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 (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 (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 (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 (14)
Microsoft.Extensions.AI.OpenAI.Tests (5)
Microsoft.Extensions.AI.Tests (41)
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)