3 types derived from ChatOptions
Microsoft.Extensions.AI.Abstractions.Tests (2)
Microsoft.Extensions.AI.Evaluation.Safety (1)
245 instantiations of ChatOptions
Aspire.Dashboard (1)
Microsoft.Extensions.AI (3)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (10)
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 (53)
ChatClientIntegrationTests.cs (23)
143var response = ChatClient.GetStreamingResponseAsync("Explain in 10 words how AI works", new()
199new() { ModelId = GetModel_MultiModal_DescribeImage() });
217new() { ModelId = GetModel_MultiModal_DescribeImage() });
244var response = await chatClient.GetResponseAsync(messages, new()
260var response = await chatClient.GetResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
275var response = chatClient.GetStreamingResponseAsync("What is the result of SecretComputation on 42 and 84?", new()
312var response = await chatClient.GetResponseAsync(messages, new()
344var response = await chatClient.GetResponseAsync(messages, new()
376var response = await chatClient.GetResponseAsync(messages, new()
453ChatOptions options = new()
582var response = await chatClient.GetResponseAsync("How much older is Elsa than Anna? Return the age difference as a single number.", new()
614var response = await chatClient.GetResponseAsync("Are birds real?", new()
635var response = await chatClient.GetResponseAsync("What's the current secret number?", new()
897new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] });
923new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] }))
1075"Who is person with ID 123?", new ChatOptions
1255var response = await chatClient.GetResponseAsync(messages, new() { Tools = [getWeather] });
1471var firstResponse = await client.GetResponseAsync(history, new ChatOptions { Tools = allTools });
1480var secondResponse = await client.GetResponseAsync(history, new ChatOptions { Tools = allTools });
1537var response = await client.GetResponseAsync(history, new ChatOptions
1600var firstResponse = await client.GetResponseAsync(history, new ChatOptions
1613var secondResponse = await client.GetResponseAsync(history, new ChatOptions
1706var response = await client.GetResponseAsync(history, new ChatOptions { Tools = allTools });
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (2)
Microsoft.Extensions.AI.OpenAI.Tests (74)
OpenAIChatClientTests.cs (14)
153var response = await client.GetResponseAsync("hello", new()
233await foreach (var update in client.GetStreamingResponseAsync("hello", new()
330var response = await client.GetResponseAsync("hello", new()
384ChatOptions chatOptions = new()
461ChatOptions chatOptions = new()
544ChatOptions chatOptions = new()
618ChatOptions chatOptions = new()
726Assert.NotNull(await client.GetResponseAsync("hello", new()
825var response = await client.GetResponseAsync(messages, new()
1139var response = await client.GetResponseAsync("How old is Alice?", new()
1223var response = await client.GetResponseAsync("What day is it?", new()
1323await foreach (var update in client.GetStreamingResponseAsync("How old is Alice?", new()
1677var response = await client.GetResponseAsync("hello", new()
1724await foreach (var update in client.GetStreamingResponseAsync("hello", new()
OpenAIResponseClientTests.cs (35)
152var response = await client.GetResponseAsync("hello", new()
296await foreach (var update in client.GetStreamingResponseAsync("Calculate the sum of the first 5 positive integers.", new()
429await foreach (var update in client.GetStreamingResponseAsync("Solve this problem step by step.", new()
560await foreach (var update in client.GetStreamingResponseAsync("hello", new()
660var response = await client.GetResponseAsync("hello", new()
806ChatOptions chatOptions = new()
933var response = await client.GetResponseAsync("hello", new()
1059var chatOptions = new ChatOptions
1444ChatOptions chatOptions = new()
1853ChatOptions chatOptions = new()
1966var response = await client.GetResponseAsync("hello", new()
2057var response = await client.GetResponseAsync([], new()
2107var options = new ChatOptions
2203await foreach (var update in client.GetStreamingResponseAsync("hello", new()
2289var chatOptions = new ChatOptions
2351var chatOptions = new ChatOptions
2475var response = await client.GetResponseAsync("Calculate the sum of numbers from 1 to 5", new()
2695var response = await client.GetStreamingResponseAsync("Calculate the sum of numbers from 1 to 10 using Python", new()
2784var response = await client.GetResponseAsync("hello", new()
2842var response = await client.GetResponseAsync("hello", new()
2901var response = await client.GetResponseAsync("hello", new()
2962var response = await client.GetResponseAsync("hello", new()
3024var response = await client.GetResponseAsync("hello", new()
3087var response = await client.GetResponseAsync("hello", new()
3161await foreach (var update in client.GetStreamingResponseAsync("hello", new()
3242await foreach (var update in client.GetStreamingResponseAsync("hello", new()
3323await foreach (var update in client.GetStreamingResponseAsync("hello", new()
3401await foreach (var update in client.GetStreamingResponseAsync("hello", new()
3472var response = await client.GetResponseAsync("hello", new()
3532var response = await client.GetResponseAsync("hello", new()
3603await foreach (var update in client.GetStreamingResponseAsync("hello", new()
4656new ChatOptions { ContinuationToken = token });
4839var response = await client.GetResponseAsync("Generate an image of a cat", new ChatOptions
4941await foreach (var update in client.GetStreamingResponseAsync("Generate an image of a dog", new ChatOptions
5060await foreach (var update in client.GetStreamingResponseAsync("Generate an image of a sunset", new ChatOptions
Microsoft.Extensions.AI.Tests (63)
Microsoft.ML.GenAI.LLaMA (2)
Microsoft.ML.GenAI.Phi (2)
375 references to ChatOptions
Aspire.Azure.AI.OpenAI.Tests (1)
Aspire.Dashboard (1)
Aspire.OpenAI.Tests (1)
Microsoft.Extensions.AI (91)
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 (14)
23/// A delegating chat client that invokes functions defined on <see cref="ChatOptions"/>.
30/// in <see cref="ChatOptions.Tools"/> (or in <see cref="AdditionalTools"/>), producing a <see cref="FunctionResultContent"/>
51/// requests not be made in a single response, by setting <see cref="ChatOptions.AllowMultipleToolCalls"/> to <see langword="false"/>.
55/// <see cref="AIFunction"/> instances employed as part of the supplied <see cref="ChatOptions"/> are also safe.
60/// ASP.NET web request should only be used as part of a single <see cref="ChatOptions"/> at a time, and only with
222/// <see cref="ChatOptions.Tools" /> unmodified. However, if the inner client requests the invocation of a tool
223/// that was not in <see cref="ChatOptions.Tools" />, this <see cref="AdditionalTools"/> collection will also be consulted
248/// <see cref="ChatOptions.Tools"/> or <see cref="AdditionalTools"/>) but that aren't <see cref="AIFunction"/>s aren't considered
266IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
405IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
785private static void UpdateOptionsForNextIteration(ref ChatOptions? options, string? conversationId)
884List<ChatMessage> messages, ChatOptions? options,
1012List<ChatMessage> messages, ChatOptions? options,
1618ChatOptions? options,
Microsoft.Extensions.AI.Abstractions (32)
Microsoft.Extensions.AI.Abstractions.Tests (21)
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 (3)
Microsoft.Extensions.AI.Integration.Tests (29)
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)
ToolReductionTests.cs (9)
29var options = new ChatOptions { Tools = tools };
63var options = new ChatOptions { Tools = tools };
125var options = new ChatOptions { Tools = [] };
430var options = new ChatOptions { Tools = tools };
454var options = new ChatOptions { Tools = tools };
646public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, Task<ChatResponse>>? GetResponseAsyncCallback { get; set; }
647public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; }
649public Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default) =>
652public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default) =>
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI (28)
OpenAIResponsesChatClient.cs (9)
96IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
251IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
494internal static ResponseTool? ToResponseTool(AITool tool, ChatOptions? options = null)
588internal static FunctionTool ToResponseTool(AIFunctionDeclaration aiFunction, ChatOptions? options = null)
651/// <summary>Converts a <see cref="ChatOptions"/> to a <see cref="ResponseCreationOptions"/>.</summary>
652private ResponseCreationOptions ToOpenAIResponseCreationOptions(ChatOptions? options, out string? openAIConversationId)
761internal static ResponseTextFormat? ToOpenAIResponseTextFormat(ChatResponseFormat? format, ChatOptions? options = null) =>
779internal static IEnumerable<ResponseItem> ToOpenAIResponseItems(IEnumerable<ChatMessage> inputs, ChatOptions? options)
1355private static OpenAIResponsesContinuationToken? GetContinuationToken(IEnumerable<ChatMessage> messages, ChatOptions? options = null)
Microsoft.Extensions.AI.OpenAI.Tests (30)
Microsoft.Extensions.AI.Tests (82)
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)