2 types derived from ChatToolMode
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\AutoChatToolMode.cs (1)
15public sealed class AutoChatToolMode : ChatToolMode
ChatCompletion\RequiredChatToolMode.cs (1)
15public sealed class RequiredChatToolMode : ChatToolMode
62 references to ChatToolMode
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvokingChatClient.cs (2)
280options.ToolMode = ChatToolMode.Auto; 396options.ToolMode = ChatToolMode.Auto;
Microsoft.Extensions.AI.Abstractions (9)
ChatCompletion\AutoChatToolMode.cs (2)
12/// Use <see cref="ChatToolMode.Auto"/> to get an instance of <see cref="AutoChatToolMode"/>. 18/// <remarks>Use <see cref="ChatToolMode.Auto"/> to get an instance of <see cref="AutoChatToolMode"/>.</remarks>
ChatCompletion\ChatOptions.cs (2)
54public ChatToolMode ToolMode { get; set; } = ChatToolMode.Auto;
ChatCompletion\ChatToolMode.cs (4)
22/// <summary>Initializes a new instance of the <see cref="ChatToolMode"/> class.</summary> 29/// Gets a predefined <see cref="ChatToolMode"/> indicating that tool usage is optional. 38/// Gets a predefined <see cref="ChatToolMode"/> indicating that tool usage is required, 44/// Instantiates a <see cref="ChatToolMode"/> indicating that tool usage is required,
ChatCompletion\RequiredChatToolMode.cs (1)
31/// <see cref="ChatToolMode.RequireAny"/> when any function can be selected.
Microsoft.Extensions.AI.Abstractions.Tests (41)
ChatCompletion\ChatOptionsTests.cs (7)
26Assert.Same(ChatToolMode.Auto, options.ToolMode); 41Assert.Same(ChatToolMode.Auto, clone.ToolMode); 78options.ToolMode = ChatToolMode.RequireAny; 92Assert.Same(ChatToolMode.RequireAny, options.ToolMode); 107Assert.Same(ChatToolMode.RequireAny, clone.ToolMode); 138options.ToolMode = ChatToolMode.RequireAny; 162Assert.Equal(ChatToolMode.RequireAny, deserialized.ToolMode);
ChatCompletion\ChatToolModeTests.cs (34)
14Assert.Same(ChatToolMode.Auto, ChatToolMode.Auto); 15Assert.Same(ChatToolMode.RequireAny, ChatToolMode.RequireAny); 21Assert.True(ChatToolMode.Auto == ChatToolMode.Auto); 22Assert.True(ChatToolMode.Auto.Equals(ChatToolMode.Auto)); 23Assert.False(ChatToolMode.Auto.Equals(ChatToolMode.RequireAny)); 24Assert.False(ChatToolMode.Auto.Equals(new RequiredChatToolMode(null))); 25Assert.False(ChatToolMode.Auto.Equals(new RequiredChatToolMode("func"))); 26Assert.Equal(ChatToolMode.Auto.GetHashCode(), ChatToolMode.Auto.GetHashCode()); 28Assert.True(ChatToolMode.RequireAny == ChatToolMode.RequireAny); 29Assert.True(ChatToolMode.RequireAny.Equals(ChatToolMode.RequireAny)); 30Assert.False(ChatToolMode.RequireAny.Equals(ChatToolMode.Auto)); 31Assert.False(ChatToolMode.RequireAny.Equals(new RequiredChatToolMode("func"))); 33Assert.True(ChatToolMode.RequireAny.Equals(new RequiredChatToolMode(null))); 34Assert.Equal(ChatToolMode.RequireAny.GetHashCode(), new RequiredChatToolMode(null).GetHashCode()); 35Assert.Equal(ChatToolMode.RequireAny.GetHashCode(), ChatToolMode.RequireAny.GetHashCode()); 50string json = JsonSerializer.Serialize(ChatToolMode.Auto, TestJsonSerializerContext.Default.ChatToolMode); 53ChatToolMode? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode); 54Assert.Equal(ChatToolMode.Auto, result); 60string json = JsonSerializer.Serialize(ChatToolMode.RequireAny, TestJsonSerializerContext.Default.ChatToolMode); 63ChatToolMode? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode); 64Assert.Equal(ChatToolMode.RequireAny, result); 70string json = JsonSerializer.Serialize(ChatToolMode.RequireSpecific("myFunc"), TestJsonSerializerContext.Default.ChatToolMode); 73ChatToolMode? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode); 74Assert.Equal(ChatToolMode.RequireSpecific("myFunc"), result);
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
AzureAIInferenceChatClientTests.cs (4)
674yield return [ChatToolMode.Auto]; 675yield return [ChatToolMode.RequireAny]; 676yield return [ChatToolMode.RequireSpecific("GetPersonAge")]; 681public async Task FunctionCallContent_NonStreaming(ChatToolMode mode)
Microsoft.Extensions.AI.Integration.Tests (2)
ChatClientIntegrationTests.cs (2)
285ToolMode = ChatToolMode.RequireAny, 307ToolMode = ChatToolMode.RequireSpecific(shieldsUpTool.Metadata.Name),
Microsoft.Extensions.AI.OpenAI (3)
OpenAIModelMapper.ChatCompletion.cs (3)
215"required" => ChatToolMode.RequireAny, 216_ => ChatToolMode.Auto, 223result.ToolMode = ChatToolMode.RequireSpecific(functionElement.GetString()!);
Microsoft.Extensions.AI.OpenAI.Tests (1)
OpenAISerializationTests.cs (1)
336Assert.Equal(ChatToolMode.Auto, request.Options.ToolMode);