2 types derived from ChatResponseFormat
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatResponseFormatJson.cs (1)
13
public sealed class ChatResponseFormatJson :
ChatResponseFormat
ChatCompletion\ChatResponseFormatText.cs (1)
13
public sealed class ChatResponseFormatText :
ChatResponseFormat
86 references to ChatResponseFormat
Microsoft.Extensions.AI (9)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (9)
29
/// <see langword="true" /> to set a JSON schema on the <see cref="
ChatResponseFormat
"/>; otherwise, <see langword="false" />. The default is <see langword="true" />.
48
/// <see langword="true" /> to set a JSON schema on the <see cref="
ChatResponseFormat
"/>; otherwise, <see langword="false" />.
68
/// <see langword="true" /> to set a JSON schema on the <see cref="
ChatResponseFormat
"/>; otherwise, <see langword="false" />. The default is <see langword="true" />.
88
/// <see langword="true" /> to set a JSON schema on the <see cref="
ChatResponseFormat
"/>; otherwise, <see langword="false" />. The default is <see langword="true" />.
109
/// <see langword="true" /> to set a JSON schema on the <see cref="
ChatResponseFormat
"/>; otherwise, <see langword="false" />. The default is <see langword="true" />.
130
/// <see langword="true" /> to set a JSON schema on the <see cref="
ChatResponseFormat
"/>; otherwise, <see langword="false" />. The default is <see langword="true" />.
151
var responseFormat =
ChatResponseFormat
.ForJsonSchema<T>(serializerOptions);
170
responseFormat =
ChatResponseFormat
.ForJsonSchema(schema, responseFormat.SchemaName, responseFormat.SchemaDescription);
187
options.ResponseFormat =
ChatResponseFormat
.Json;
Microsoft.Extensions.AI.Abstractions (7)
ChatCompletion\ChatOptions.cs (4)
72
/// This property can be set to <see cref="
ChatResponseFormat
.Text"/> to specify that the response should be unstructured text,
73
/// to <see cref="
ChatResponseFormat
.Json"/> to specify that the response should be structured JSON data, or
76
/// to honor the request. If the client implementation doesn't recognize the specific kind of <see cref="
ChatResponseFormat
"/>,
79
public
ChatResponseFormat
? ResponseFormat { get; set; }
ChatCompletion\ChatResponseFormat.cs (1)
27
/// <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 (27)
ChatCompletion\ChatOptionsTests.cs (4)
88
options.ResponseFormat =
ChatResponseFormat
.Json;
106
Assert.Same(
ChatResponseFormat
.Json, options.ResponseFormat);
124
Assert.Same(
ChatResponseFormat
.Json, clone.ResponseFormat);
159
options.ResponseFormat =
ChatResponseFormat
.Json;
ChatCompletion\ChatResponseFormatTests.cs (21)
22
Assert.Same(
ChatResponseFormat
.Text,
ChatResponseFormat
.Text);
23
Assert.Same(
ChatResponseFormat
.Json,
ChatResponseFormat
.Json);
55
string json = JsonSerializer.Serialize(
ChatResponseFormat
.Text, TestJsonSerializerContext.Default.ChatResponseFormat);
58
ChatResponseFormat
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat);
59
Assert.Equal(
ChatResponseFormat
.Text, result);
65
string json = JsonSerializer.Serialize(
ChatResponseFormat
.Json, TestJsonSerializerContext.Default.ChatResponseFormat);
68
ChatResponseFormat
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat);
79
ChatResponseFormat
.ForJsonSchema(JsonSerializer.Deserialize<JsonElement>("[1,2,3]", AIJsonUtilities.DefaultOptions), "name", "description"),
83
ChatResponseFormat
? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat);
93
Assert.Throws<ArgumentNullException>("schemaType", () =>
ChatResponseFormat
.ForJsonSchema(null!));
94
Assert.Throws<ArgumentNullException>("schemaType", () =>
ChatResponseFormat
.ForJsonSchema(null!, TestJsonSerializerContext.Default.Options));
95
Assert.Throws<ArgumentNullException>("schemaType", () =>
ChatResponseFormat
.ForJsonSchema(null!, TestJsonSerializerContext.Default.Options, "name"));
96
Assert.Throws<ArgumentNullException>("schemaType", () =>
ChatResponseFormat
.ForJsonSchema(null!, TestJsonSerializerContext.Default.Options, "name", "description"));
105
ChatResponseFormat
.ForJsonSchema<int>() :
106
ChatResponseFormat
.ForJsonSchema(typeof(int));
121
ChatResponseFormat
.ForJsonSchema<DataContent>() :
122
ChatResponseFormat
.ForJsonSchema(typeof(DataContent));
142
ChatResponseFormat
.ForJsonSchema<SomeType>(TestJsonSerializerContext.Default.Options, name, description) :
143
ChatResponseFormat
.ForJsonSchema(typeof(SomeType), TestJsonSerializerContext.Default.Options, name, description);
Utilities\AIJsonSchemaTransformCacheTests.cs (2)
65
ChatResponseFormatJson responseFormat =
ChatResponseFormat
.ForJsonSchema(schema);
78
JsonElement? transformedSchema = cache.GetOrCreateTransformedSchema(
ChatResponseFormat
.Json);
Microsoft.Extensions.AI.AzureAIInference.Tests (7)
AzureAIInferenceChatClientTests.cs (7)
361
ResponseFormat =
ChatResponseFormat
.Json,
445
ResponseFormat =
ChatResponseFormat
.Json,
532
ResponseFormat =
ChatResponseFormat
.Json
607
ResponseFormat =
ChatResponseFormat
.Json
796
ResponseFormat =
ChatResponseFormat
.Text,
832
ResponseFormat =
ChatResponseFormat
.Json,
889
ResponseFormat =
ChatResponseFormat
.ForJsonSchema(JsonSerializer.Deserialize<JsonElement>("""
Microsoft.Extensions.AI.Evaluation.Integration.Tests (4)
AgentQualityEvaluatorTests.cs (2)
35
ResponseFormat =
ChatResponseFormat
.Text
42
ResponseFormat =
ChatResponseFormat
.Text,
QualityEvaluatorTests.cs (1)
36
ResponseFormat =
ChatResponseFormat
.Text
SafetyEvaluatorTests.cs (1)
38
ResponseFormat =
ChatResponseFormat
.Text
Microsoft.Extensions.AI.Evaluation.Quality (12)
CoherenceEvaluator.cs (1)
63
ResponseFormat =
ChatResponseFormat
.Text
CompletenessEvaluator.cs (1)
60
ResponseFormat =
ChatResponseFormat
.Text
EquivalenceEvaluator.cs (1)
59
ResponseFormat =
ChatResponseFormat
.Text
FluencyEvaluator.cs (1)
57
ResponseFormat =
ChatResponseFormat
.Text
GroundednessEvaluator.cs (1)
58
ResponseFormat =
ChatResponseFormat
.Text
IntentResolutionEvaluator.cs (1)
71
ResponseFormat =
ChatResponseFormat
.Json
RelevanceEvaluator.cs (1)
61
ResponseFormat =
ChatResponseFormat
.Text
RelevanceTruthAndCompletenessEvaluator.cs (1)
74
ResponseFormat =
ChatResponseFormat
.Json
RetrievalEvaluator.cs (1)
67
ResponseFormat =
ChatResponseFormat
.Text
TaskAdherenceEvaluator.cs (1)
70
ResponseFormat =
ChatResponseFormat
.Text
ToolCallAccuracyEvaluator.cs (1)
72
ResponseFormat =
ChatResponseFormat
.Text
Utilities\JsonOutputFixer.cs (1)
62
ResponseFormat =
ChatResponseFormat
.Json
Microsoft.Extensions.AI.OpenAI (6)
MicrosoftExtensionsAIChatExtensions.cs (2)
30
/// Creates an OpenAI <see cref="ChatResponseFormat"/> from a <see cref="Microsoft.Extensions.AI.
ChatResponseFormat
"/>.
35
public static ChatResponseFormat? AsOpenAIChatResponseFormat(this Microsoft.Extensions.AI.
ChatResponseFormat
? format, ChatOptions? options = null) =>
MicrosoftExtensionsAIResponsesExtensions.cs (2)
25
/// Creates an OpenAI <see cref="ResponseTextFormat"/> from a <see cref="
ChatResponseFormat
"/>.
30
public static ResponseTextFormat? AsOpenAIResponseTextFormat(this
ChatResponseFormat
? format, ChatOptions? options = null) =>
OpenAIChatClient.cs (1)
622
internal static OpenAI.Chat.ChatResponseFormat? ToOpenAIChatResponseFormat(
ChatResponseFormat
? format, ChatOptions? options) =>
OpenAIResponsesChatClient.cs (1)
551
internal static ResponseTextFormat? ToOpenAIResponseTextFormat(
ChatResponseFormat
? format, ChatOptions? options = null) =>
Microsoft.Extensions.AI.OpenAI.Tests (13)
OpenAIChatClientTests.cs (4)
413
ResponseFormat =
ChatResponseFormat
.Json
490
ResponseFormat =
ChatResponseFormat
.Json
571
ResponseFormat =
ChatResponseFormat
.Json
645
ResponseFormat =
ChatResponseFormat
.Json
OpenAIConversionTests.cs (8)
32
var text = MicrosoftExtensionsAIChatExtensions.AsOpenAIChatResponseFormat(
ChatResponseFormat
.Text);
36
var json = MicrosoftExtensionsAIChatExtensions.AsOpenAIChatResponseFormat(
ChatResponseFormat
.Json);
40
var jsonSchema =
ChatResponseFormat
.ForJsonSchema(typeof(int), schemaName: "my_schema", schemaDescription: "A test schema").AsOpenAIChatResponseFormat();
49
jsonSchema =
ChatResponseFormat
.ForJsonSchema(typeof(int), schemaName: "my_schema", schemaDescription: "A test schema").AsOpenAIChatResponseFormat(
66
var text = MicrosoftExtensionsAIResponsesExtensions.AsOpenAIResponseTextFormat(
ChatResponseFormat
.Text);
70
var json = MicrosoftExtensionsAIResponsesExtensions.AsOpenAIResponseTextFormat(
ChatResponseFormat
.Json);
74
var jsonSchema =
ChatResponseFormat
.ForJsonSchema(typeof(int), schemaName: "my_schema", schemaDescription: "A test schema").AsOpenAIResponseTextFormat();
84
jsonSchema =
ChatResponseFormat
.ForJsonSchema(typeof(int), schemaName: "my_schema", schemaDescription: "A test schema").AsOpenAIResponseTextFormat(
OpenAIResponseClientTests.cs (1)
704
ResponseFormat =
ChatResponseFormat
.Json
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
123
ResponseFormat =
ChatResponseFormat
.Json,