2 types derived from ChatToolMode
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\AutoChatToolMode.cs (1)
15
public sealed class AutoChatToolMode :
ChatToolMode
ChatCompletion\RequiredChatToolMode.cs (1)
15
public sealed class RequiredChatToolMode :
ChatToolMode
54 references to ChatToolMode
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvokingChatClient.cs (2)
274
options.ToolMode =
ChatToolMode
.Auto;
380
options.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)
54
public
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)
26
Assert.Same(
ChatToolMode
.Auto, options.ToolMode);
41
Assert.Same(
ChatToolMode
.Auto, clone.ToolMode);
78
options.ToolMode =
ChatToolMode
.RequireAny;
92
Assert.Same(
ChatToolMode
.RequireAny, options.ToolMode);
107
Assert.Same(
ChatToolMode
.RequireAny, clone.ToolMode);
138
options.ToolMode =
ChatToolMode
.RequireAny;
163
Assert.Equal(
ChatToolMode
.RequireAny, deserialized.ToolMode);
ChatCompletion\ChatToolModeTests.cs (34)
14
Assert.Same(
ChatToolMode
.Auto,
ChatToolMode
.Auto);
15
Assert.Same(
ChatToolMode
.RequireAny,
ChatToolMode
.RequireAny);
21
Assert.True(
ChatToolMode
.Auto ==
ChatToolMode
.Auto);
22
Assert.True(
ChatToolMode
.Auto.Equals(
ChatToolMode
.Auto));
23
Assert.False(
ChatToolMode
.Auto.Equals(
ChatToolMode
.RequireAny));
24
Assert.False(
ChatToolMode
.Auto.Equals(new RequiredChatToolMode(null)));
25
Assert.False(
ChatToolMode
.Auto.Equals(new RequiredChatToolMode("func")));
26
Assert.Equal(
ChatToolMode
.Auto.GetHashCode(),
ChatToolMode
.Auto.GetHashCode());
28
Assert.True(
ChatToolMode
.RequireAny ==
ChatToolMode
.RequireAny);
29
Assert.True(
ChatToolMode
.RequireAny.Equals(
ChatToolMode
.RequireAny));
30
Assert.False(
ChatToolMode
.RequireAny.Equals(
ChatToolMode
.Auto));
31
Assert.False(
ChatToolMode
.RequireAny.Equals(new RequiredChatToolMode("func")));
33
Assert.True(
ChatToolMode
.RequireAny.Equals(new RequiredChatToolMode(null)));
34
Assert.Equal(
ChatToolMode
.RequireAny.GetHashCode(), new RequiredChatToolMode(null).GetHashCode());
35
Assert.Equal(
ChatToolMode
.RequireAny.GetHashCode(),
ChatToolMode
.RequireAny.GetHashCode());
50
string json = JsonSerializer.Serialize(
ChatToolMode
.Auto, TestJsonSerializerContext.Default.ChatToolMode);
53
ChatToolMode
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode);
54
Assert.Equal(
ChatToolMode
.Auto, result);
60
string json = JsonSerializer.Serialize(
ChatToolMode
.RequireAny, TestJsonSerializerContext.Default.ChatToolMode);
63
ChatToolMode
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode);
64
Assert.Equal(
ChatToolMode
.RequireAny, result);
70
string json = JsonSerializer.Serialize(
ChatToolMode
.RequireSpecific("myFunc"), TestJsonSerializerContext.Default.ChatToolMode);
73
ChatToolMode
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode);
74
Assert.Equal(
ChatToolMode
.RequireSpecific("myFunc"), result);
Microsoft.Extensions.AI.Integration.Tests (2)
ChatClientIntegrationTests.cs (2)
275
ToolMode =
ChatToolMode
.RequireAny,
297
ToolMode =
ChatToolMode
.RequireSpecific(shieldsUpTool.Metadata.Name),