3 types derived from ChatOptions
Microsoft.Extensions.AI.Abstractions.Tests (2)
Microsoft.Extensions.AI.Evaluation.Safety (1)
308 instantiations of ChatOptions
Microsoft.AspNetCore.Components.AI (2)
Microsoft.Extensions.AI (3)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (13)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (4)
Microsoft.Extensions.AI.Evaluation.Quality (12)
Microsoft.Extensions.AI.Integration.Tests (24)
ChatClientIntegrationTests.cs (17)
133var response = ChatClient.GetStreamingResponseAsync("Explain in 10 words how AI works", new()
189new() { ModelId = GetModel_MultiModal_DescribeImage() });
207new() { ModelId = GetModel_MultiModal_DescribeImage() });
234var response = await chatClient.GetResponseAsync(messages, new()
250var response = await chatClient.GetResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
265var response = chatClient.GetStreamingResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
302var response = await chatClient.GetResponseAsync(messages, new()
334var response = await chatClient.GetResponseAsync(messages, new()
366var response = await chatClient.GetResponseAsync(messages, new()
443ChatOptions 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
1247var response = await chatClient.GetResponseAsync(messages, new() { Tools = [getWeather] });
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (2)
Microsoft.Extensions.AI.OpenAI.Tests (120)
OpenAIChatClientTests.cs (15)
155var response = await client.GetResponseAsync("hello", new()
235await foreach (var update in client.GetStreamingResponseAsync("hello", new()
332var response = await client.GetResponseAsync("hello", new()
386ChatOptions chatOptions = new()
463ChatOptions chatOptions = new()
546ChatOptions chatOptions = new()
620ChatOptions chatOptions = new()
728Assert.NotNull(await client.GetResponseAsync("hello", new()
827var response = await client.GetResponseAsync(messages, new()
1141var response = await client.GetResponseAsync("How old is Alice?", new()
1226var response = await client.GetResponseAsync("What day is it?", new()
1326await foreach (var update in client.GetStreamingResponseAsync("How old is Alice?", new()
1685var response = await client.GetResponseAsync("hello", new()
1732await foreach (var update in client.GetStreamingResponseAsync("hello", new()
1870Assert.NotNull(await client.GetResponseAsync("hello", new()
OpenAIResponseClientTests.cs (67)
153var response = await client.GetResponseAsync("hello", new()
297await foreach (var update in client.GetStreamingResponseAsync("Calculate the sum of the first 5 positive integers.", new()
427await foreach (var update in client.GetStreamingResponseAsync("Solve this problem step by step.", new()
553await foreach (var update in client.GetStreamingResponseAsync("Solve this problem step by step.", new()
628await foreach (var update in client.GetStreamingResponseAsync("Solve this problem step by step.", new()
653await client.GetResponseAsync(chatHistory, new()
747await foreach (var update in client.GetStreamingResponseAsync("hello", new()
886ChatOptions chatOptions = new()
982ChatOptions chatOptions = new()
1088var response = await client.GetResponseAsync("hello", new()
1234ChatOptions chatOptions = new()
1361var response = await client.GetResponseAsync("hello", new()
1485var chatOptions = new ChatOptions
1990ChatOptions chatOptions = new()
2396ChatOptions chatOptions = new()
2610ChatOptions chatOptions = new()
2724var response = await client.GetResponseAsync("hello", new ChatOptions { Tools = [mcpTool] });
2814var response = await client.GetResponseAsync("hello", new ChatOptions { Tools = [mcpTool] });
2876var response = await client.GetResponseAsync("hello", new()
2967var response = await client.GetResponseAsync([], new()
3017var options = new ChatOptions
3113await foreach (var update in client.GetStreamingResponseAsync("hello", new()
3199var chatOptions = new ChatOptions
3261var chatOptions = new ChatOptions
3384var response = await client.GetResponseAsync("Calculate the sum of numbers from 1 to 5", new()
3604var response = await client.GetStreamingResponseAsync("Calculate the sum of numbers from 1 to 10 using Python", new()
3692await foreach (var update in client.GetStreamingResponseAsync("Calculate the sum of numbers from 1 to 10 using Python", new()
3812var response = await client.GetResponseAsync("hello", new()
3870var response = await client.GetResponseAsync("hello", new()
3929var response = await client.GetResponseAsync("hello", new()
3990var response = await client.GetResponseAsync("hello", new()
4052var response = await client.GetResponseAsync("hello", new()
4115var response = await client.GetResponseAsync("hello", new()
4189await foreach (var update in client.GetStreamingResponseAsync("hello", new()
4270await foreach (var update in client.GetStreamingResponseAsync("hello", new()
4340var response = await client.GetResponseAsync("hello", new()
4411await foreach (var update in client.GetStreamingResponseAsync("hello", new()
4488await foreach (var update in client.GetStreamingResponseAsync("hello", new()
4566await foreach (var update in client.GetStreamingResponseAsync("hello", new()
4631var response = await client.GetResponseAsync("hello", new()
4692var response = await client.GetResponseAsync("hello", new()
4763await foreach (var update in client.GetStreamingResponseAsync("hello", new()
5865new ChatOptions { ContinuationToken = token });
6413var response = await client.GetResponseAsync("Generate an image of a cat", new ChatOptions
6514await foreach (var update in client.GetStreamingResponseAsync("Generate an image of a dog", new ChatOptions
6632await foreach (var update in client.GetStreamingResponseAsync("Generate an image of a sunset", new ChatOptions
6751Assert.NotNull(await client.GetResponseAsync("hello", new()
6890var response = await client.GetResponseAsync("Create a hello world file", new()
7172var response = await client.GetResponseAsync("What is the latest news about .NET?", new()
7300await foreach (var update in client.GetStreamingResponseAsync("What is the latest news about .NET?", new()
7409var response = await client.GetResponseAsync("hello", new()
7496var response = await client.GetResponseAsync("hello", new()
7588var response = await client.GetResponseAsync("hello", new()
7655var response = await client.GetResponseAsync("hello", new()
7765var response = await client.GetResponseAsync("hello", new()
7865var response = await client.GetResponseAsync("hello", new()
7970var response = await client.GetResponseAsync("hello", new()
8070var response = await client.GetResponseAsync("hello", new()
8157var response = await client.GetResponseAsync("hello", new()
8248var response = await client.GetResponseAsync("hello", new()
8334var response = await client.GetResponseAsync("hello", new()
8447var response = await client.GetResponseAsync("hello", new()
8546var response = await client.GetResponseAsync("hello", new()
8650var response = await client.GetResponseAsync("hello", new()
8763var response = await client.GetResponseAsync("hello", new()
8883new ChatOptions { Tools = [tool] });
8977new ChatOptions { Tools = [tool] }))
Microsoft.Extensions.AI.Tests (123)
Microsoft.ML.GenAI.LLaMA (2)
Microsoft.ML.GenAI.Phi (2)
443 references to ChatOptions
Aspire.Azure.AI.OpenAI.Tests (1)
Aspire.OpenAI.Tests (1)
Microsoft.AspNetCore.Components.AI (7)
Microsoft.Extensions.AI (87)
ChatCompletion\AnonymousDelegatingChatClient.cs (11)
21private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? _getResponseFunc;
29private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc;
32private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task>? _sharedFunc;
51Func<IEnumerable<ChatMessage>, ChatOptions?, Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task>, CancellationToken, Task> sharedFunc)
77Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, Task<ChatResponse>>? getResponseFunc,
78Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
89IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
98IEnumerable<ChatMessage> messages, ChatOptions? options, CancellationToken cancellationToken)
128IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
ChatCompletion\CachingChatClient.cs (8)
47IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
57IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
75IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
85IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
147/// <param name="options">The <see cref="ChatOptions"/> to inform the key.</param>
150protected abstract string GetCacheKey(IEnumerable<ChatMessage> messages, ChatOptions? options, params ReadOnlySpan<object?> additionalValues);
207/// does not have a <see cref="ChatOptions.ConversationId"/> set.
209protected 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 (15)
25/// A delegating chat client that invokes functions defined on <see cref="ChatOptions"/>.
32/// in <see cref="ChatOptions.Tools"/> (or in <see cref="AdditionalTools"/>), producing a <see cref="FunctionResultContent"/>
53/// requests not be made in a single response, by setting <see cref="ChatOptions.AllowMultipleToolCalls"/> to <see langword="false"/>.
57/// <see cref="AIFunction"/> instances employed as part of the supplied <see cref="ChatOptions"/> are also safe.
62/// ASP.NET web request should only be used as part of a single <see cref="ChatOptions"/> at a time, and only with
234/// <see cref="ChatOptions.Tools" /> unmodified. However, if the inner client requests the invocation of a tool
235/// that was not in <see cref="ChatOptions.Tools" />, this <see cref="AdditionalTools"/> collection will also be consulted
260/// <see cref="ChatOptions.Tools"/> or <see cref="AdditionalTools"/>) but that aren't <see cref="AIFunction"/>s aren't considered
278IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
438IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
1007private static void UpdateOptionsForNextIteration(ref ChatOptions? options, string? conversationId)
1055private static void PrepareOptionsForLastIteration(ref ChatOptions? options)
1091private bool ShouldTerminateLoopBasedOnHandleableFunctions(List<FunctionCallContent>? functionCalls, ChatOptions? options)
1163List<ChatMessage> messages, ChatOptions? options,
1813ChatOptions? options,
Microsoft.Extensions.AI.Abstractions (34)
Microsoft.Extensions.AI.Abstractions.Tests (31)
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.Evaluation.Integration.Tests (4)
Microsoft.Extensions.AI.Evaluation.Quality (21)
Microsoft.Extensions.AI.Evaluation.Reporting (3)
Microsoft.Extensions.AI.Evaluation.Safety (3)
Microsoft.Extensions.AI.Integration.Tests (19)
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 (21)
OpenAIResponsesChatClient.cs (9)
102IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
326IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
724internal static ResponseTool? ToResponseTool(AITool tool, ChatOptions? options = null, ToolSearchLookup? toolSearchLookup = null)
870internal static FunctionTool ToResponseTool(AIFunctionDeclaration aiFunction, ChatOptions? options = null)
952/// <summary>Converts a <see cref="ChatOptions"/> to a <see cref="CreateResponseOptions"/>.</summary>
953private CreateResponseOptions AsCreateResponseOptions(ChatOptions? options, out string? openAIConversationId)
1232internal static ResponseTextFormat? ToOpenAIResponseTextFormat(ChatResponseFormat? format, ChatOptions? options = null) =>
1286internal static IEnumerable<ResponseItem> ToOpenAIResponseItems(IEnumerable<ChatMessage> inputs, ChatOptions? options)
2041private static ResponsesClientContinuationToken? GetContinuationToken(IEnumerable<ChatMessage> messages, ChatOptions? options = null)
Microsoft.Extensions.AI.OpenAI.Tests (37)
Microsoft.Extensions.AI.Tests (159)
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (41)
29var options = new ChatOptions
61var options = new ChatOptions
109var options = new ChatOptions
165var options = new ChatOptions { Tools = tools };
204var options = new ChatOptions
245var options = new ChatOptions
296var options = new ChatOptions
349var options = new ChatOptions
408var options = new ChatOptions
467var options = new ChatOptions
531var options = new ChatOptions
596var options = new ChatOptions
690var options = new ChatOptions
747var options = new ChatOptions
801var options = new ChatOptions
881var options = new ChatOptions
953var options = new ChatOptions
1017var options = new ChatOptions
1072var options = new ChatOptions
1102var options = new ChatOptions
1148var options = new ChatOptions
1196var options = new ChatOptions
1246var options = new ChatOptions
1292var options = new ChatOptions
1347var options = new ChatOptions
1398var options = new ChatOptions
1458var options = new ChatOptions
1475IEnumerable<ChatMessage> contents, ChatOptions? actualOptions, [EnumeratorCancellation] CancellationToken actualCancellationToken)
1533var options = new ChatOptions
1551IEnumerable<ChatMessage> contents, ChatOptions? actualOptions, [EnumeratorCancellation] CancellationToken actualCancellationToken)
1632var options = new ChatOptions
1672var options = new ChatOptions
1729var options = new ChatOptions
1772var options = new ChatOptions
1856var options = new ChatOptions
1932ChatOptions? options,
1949ChatOptions? options,
2020ChatOptions? options,
2037ChatOptions? options,
2125IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
2132IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
ChatCompletion\OpenTelemetryChatClientTests.cs (6)
67IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
122var options = new ChatOptions
419IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
673IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
914IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
1101IEnumerable<ChatMessage> messages, ChatOptions? options, [EnumeratorCancellation] CancellationToken cancellationToken)
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.DataIngestion (1)
Microsoft.Extensions.DataIngestion.Tests (4)
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)