34 instantiations of ChatResponseFormatJson
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatResponseFormat.cs (2)
28public static ChatResponseFormatJson Json { get; } = new(schema: null); 37new(Throw.IfNull(schema),
Microsoft.Extensions.AI.Abstractions.Tests (32)
ChatCompletion\ChatResponseFormatTests.cs (32)
22Assert.Throws<ArgumentException>("schemaName", () => new ChatResponseFormatJson(null, "name")); 23Assert.Throws<ArgumentException>("schemaDescription", () => new ChatResponseFormatJson(null, null, "description")); 24Assert.Throws<ArgumentException>("schemaName", () => new ChatResponseFormatJson(null, "name", "description")); 30ChatResponseFormatJson f = new(null); 39ChatResponseFormatJson f = new("{}", "name", "description"); 52Assert.False(ChatResponseFormat.Text.Equals(new ChatResponseFormatJson(null))); 53Assert.False(ChatResponseFormat.Text.Equals(new ChatResponseFormatJson("{}"))); 58Assert.False(ChatResponseFormat.Json.Equals(new ChatResponseFormatJson("{}"))); 60Assert.True(ChatResponseFormat.Json.Equals(new ChatResponseFormatJson(null))); 61Assert.Equal(ChatResponseFormat.Json.GetHashCode(), new ChatResponseFormatJson(null).GetHashCode()); 63Assert.True(new ChatResponseFormatJson("{}").Equals(new ChatResponseFormatJson("{}"))); 64Assert.Equal(new ChatResponseFormatJson("{}").GetHashCode(), new ChatResponseFormatJson("{}").GetHashCode()); 66Assert.False(new ChatResponseFormatJson("""{ "prop": 42 }""").Equals(new ChatResponseFormatJson("""{ "prop": 43 }"""))); 67Assert.NotEqual(new ChatResponseFormatJson("""{ "prop": 42 }""").GetHashCode(), new ChatResponseFormatJson("""{ "prop": 43 }""").GetHashCode()); // technically not guaranteed 69Assert.False(new ChatResponseFormatJson("""{ "prop": 42 }""").Equals(new ChatResponseFormatJson("""{ "PROP": 42 }"""))); 70Assert.NotEqual(new ChatResponseFormatJson("""{ "prop": 42 }""").GetHashCode(), new ChatResponseFormatJson("""{ "PROP": 42 }""").GetHashCode()); // technically not guaranteed 72Assert.True(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name", "description"))); 73Assert.False(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name", "description2"))); 74Assert.False(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name2", "description"))); 75Assert.False(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name2", "description2"))); 77Assert.Equal(new ChatResponseFormatJson("{}", "name", "description").GetHashCode(), new ChatResponseFormatJson("{}", "name", "description").GetHashCode());
25 references to ChatResponseFormatJson
Microsoft.Extensions.AI (2)
ChatCompletion\OpenTelemetryChatClient.cs (2)
280ChatResponseFormatJson { Schema: null } => "json_schema", 281ChatResponseFormatJson => "json_object",
Microsoft.Extensions.AI.Abstractions (9)
ChatCompletion\ChatOptions.cs (1)
40/// an instance of <see cref="ChatResponseFormatJson"/> constructed with a specific JSON schema to request that the
ChatCompletion\ChatResponseFormat.cs (5)
13[JsonDerivedType(typeof(ChatResponseFormatJson), typeDiscriminator: "json")] 28public static ChatResponseFormatJson Json { get; } = new(schema: null); 30/// <summary>Creates a <see cref="ChatResponseFormatJson"/> representing structured JSON data with the specified schema.</summary> 34/// <returns>The <see cref="ChatResponseFormatJson"/> instance.</returns> 35public static ChatResponseFormatJson ForJsonSchema(
ChatCompletion\ChatResponseFormatJson.cs (3)
16/// <summary>Initializes a new instance of the <see cref="ChatResponseFormatJson"/> class with the specified schema.</summary> 47obj is ChatResponseFormatJson other && 55typeof(ChatResponseFormatJson).GetHashCode();
Microsoft.Extensions.AI.Abstractions.Tests (5)
ChatCompletion\ChatResponseFormatTests.cs (5)
30ChatResponseFormatJson f = new(null); 39ChatResponseFormatJson f = new("{}", "name", "description"); 108Assert.Equal("[1,2,3]", (result as ChatResponseFormatJson)?.Schema); 109Assert.Equal("name", (result as ChatResponseFormatJson)?.SchemaName); 110Assert.Equal("description", (result as ChatResponseFormatJson)?.SchemaDescription);
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
365else if (options.ResponseFormat is ChatResponseFormatJson)
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
261Format = options?.ResponseFormat is ChatResponseFormatJson ? "json" : null,
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
479else if (options.ResponseFormat is ChatResponseFormatJson jsonFormat)
Microsoft.Extensions.AI.Tests (6)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (6)
33var responseFormat = Assert.IsType<ChatResponseFormatJson>(options!.ResponseFormat); 177var responseFormat = Assert.IsType<ChatResponseFormatJson>(options!.ResponseFormat); 219var responseFormat = Assert.IsType<ChatResponseFormatJson>(options!.ResponseFormat);