Skip to content

Commit 2a04e87

Browse files
Tweak strict mode signature, fix failing tests.
1 parent d54f41e commit 2a04e87

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private protected ChatResponseFormat()
3333
/// <param name="schemaIsStrict">Whether the response should strictly adhere to the schema.</param>
3434
/// <returns>The <see cref="ChatResponseFormatJson"/> instance.</returns>
3535
public static ChatResponseFormatJson ForJsonSchema(
36-
JsonElement schema, string? schemaName = null, string? schemaDescription = null, bool schemaIsStrict = false) =>
36+
JsonElement schema, string? schemaName = null, string? schemaDescription = null, bool? schemaIsStrict = false) =>
3737
new(schema,
3838
schemaName,
3939
schemaDescription,

src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormatJson.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public sealed class ChatResponseFormatJson : ChatResponseFormat
1919
/// <param name="schemaIsStrict">Whether the response should strictly adhere to the schema.</param>
2020
[JsonConstructor]
2121
public ChatResponseFormatJson(
22-
JsonElement? schema, string? schemaName = null, string? schemaDescription = null, bool schemaIsStrict = false)
22+
JsonElement? schema, string? schemaName = null, string? schemaDescription = null, bool? schemaIsStrict = null)
2323
{
2424
if (schema is null && (schemaName is not null || schemaDescription is not null))
2525
{
@@ -44,8 +44,7 @@ public ChatResponseFormatJson(
4444
public string? SchemaDescription { get; }
4545

4646
/// <summary>Gets a value indicating whether the response should strictly adhere to the schema.</summary>
47-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
48-
public bool SchemaIsStrict { get; }
47+
public bool? SchemaIsStrict { get; }
4948

5049
/// <summary>Gets a string representing this instance to display in the debugger.</summary>
5150
[DebuggerBrowsable(DebuggerBrowsableState.Never)]

test/Libraries/Microsoft.Extensions.AI.AzureAIInference.Tests/AzureAIInferenceChatClientTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ public async Task ResponseFormat_JsonSchema_NonStreaming()
385385
"required":["description"],
386386
"additionalProperties":false
387387
},
388-
"description":"An object with a description"
388+
"description":"An object with a description",
389+
"strict":false
389390
}
390391
}
391392
}

0 commit comments

Comments
 (0)