2 types derived from ChatResponseFormat
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatResponseFormatJson.cs (1)
14
public sealed class ChatResponseFormatJson :
ChatResponseFormat
ChatCompletion\ChatResponseFormatText.cs (1)
13
public sealed class ChatResponseFormatText :
ChatResponseFormat
52 references to ChatResponseFormat
Microsoft.Extensions.AI (6)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (6)
33
/// Optionally specifies whether to set a JSON schema on the <see cref="
ChatResponseFormat
"/>.
57
/// Optionally specifies whether to set a JSON schema on the <see cref="
ChatResponseFormat
"/>.
78
/// Optionally specifies whether to set a JSON schema on the <see cref="
ChatResponseFormat
"/>.
100
/// Optionally specifies whether to set a JSON schema on the <see cref="
ChatResponseFormat
"/>.
163
options.ResponseFormat =
ChatResponseFormat
.ForJsonSchema(
170
options.ResponseFormat =
ChatResponseFormat
.Json;
Microsoft.Extensions.AI.Abstractions (7)
ChatCompletion\ChatOptions.cs (4)
38
/// This property can be set to <see cref="
ChatResponseFormat
.Text"/> to specify that the response should be unstructured text,
39
/// to <see cref="
ChatResponseFormat
.Json"/> to specify that the response should be structured JSON data, or
42
/// to honor the request. If the client implementation doesn't recognize the specific kind of <see cref="
ChatResponseFormat
"/>,
45
public
ChatResponseFormat
? ResponseFormat { get; set; }
ChatCompletion\ChatResponseFormat.cs (1)
18
/// <summary>Initializes a new instance of the <see cref="
ChatResponseFormat
"/> class.</summary>
ChatCompletion\ChatResponseFormatText.cs (2)
10
/// Use <see cref="
ChatResponseFormat
.Text"/> to get an instance of <see cref="ChatResponseFormatText"/>.
16
/// <remarks> Use <see cref="
ChatResponseFormat
.Text"/> to get an instance of <see cref="ChatResponseFormatText"/>.</remarks>
Microsoft.Extensions.AI.Abstractions.Tests (38)
ChatCompletion\ChatOptionsTests.cs (6)
75
options.ResponseFormat =
ChatResponseFormat
.Json;
89
Assert.Same(
ChatResponseFormat
.Json, options.ResponseFormat);
104
Assert.Same(
ChatResponseFormat
.Json, clone.ResponseFormat);
135
options.ResponseFormat =
ChatResponseFormat
.Json;
158
Assert.Equal(
ChatResponseFormat
.Json, deserialized.ResponseFormat);
159
Assert.NotSame(
ChatResponseFormat
.Json, deserialized.ResponseFormat);
ChatCompletion\ChatResponseFormatTests.cs (32)
15
Assert.Same(
ChatResponseFormat
.Text,
ChatResponseFormat
.Text);
16
Assert.Same(
ChatResponseFormat
.Json,
ChatResponseFormat
.Json);
48
Assert.True(
ChatResponseFormat
.Text ==
ChatResponseFormat
.Text);
49
Assert.True(
ChatResponseFormat
.Text.Equals(
ChatResponseFormat
.Text));
50
Assert.Equal(
ChatResponseFormat
.Text.GetHashCode(),
ChatResponseFormat
.Text.GetHashCode());
51
Assert.False(
ChatResponseFormat
.Text.Equals(
ChatResponseFormat
.Json));
52
Assert.False(
ChatResponseFormat
.Text.Equals(new ChatResponseFormatJson(null)));
53
Assert.False(
ChatResponseFormat
.Text.Equals(new ChatResponseFormatJson("{}")));
55
Assert.True(
ChatResponseFormat
.Json ==
ChatResponseFormat
.Json);
56
Assert.True(
ChatResponseFormat
.Json.Equals(
ChatResponseFormat
.Json));
57
Assert.False(
ChatResponseFormat
.Json.Equals(
ChatResponseFormat
.Text));
58
Assert.False(
ChatResponseFormat
.Json.Equals(new ChatResponseFormatJson("{}")));
60
Assert.True(
ChatResponseFormat
.Json.Equals(new ChatResponseFormatJson(null)));
61
Assert.Equal(
ChatResponseFormat
.Json.GetHashCode(), new ChatResponseFormatJson(null).GetHashCode());
83
string json = JsonSerializer.Serialize(
ChatResponseFormat
.Text, TestJsonSerializerContext.Default.ChatResponseFormat);
86
ChatResponseFormat
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat);
87
Assert.Equal(
ChatResponseFormat
.Text, result);
93
string json = JsonSerializer.Serialize(
ChatResponseFormat
.Json, TestJsonSerializerContext.Default.ChatResponseFormat);
96
ChatResponseFormat
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat);
97
Assert.Equal(
ChatResponseFormat
.Json, result);
103
string json = JsonSerializer.Serialize(
ChatResponseFormat
.ForJsonSchema("[1,2,3]", "name", "description"), TestJsonSerializerContext.Default.ChatResponseFormat);
106
ChatResponseFormat
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat);
107
Assert.Equal(
ChatResponseFormat
.ForJsonSchema("[1,2,3]", "name", "description"), result);
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
116
ResponseFormat =
ChatResponseFormat
.Json,