diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index b59131230513..d95b5660e9dc 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -63,9 +63,9 @@ - - - + + + diff --git a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs index d7952fa42afa..7447b230ec63 100644 --- a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs +++ b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs @@ -162,7 +162,7 @@ public async IAsyncEnumerable GetStreamingChatMessa { "text" => ChatResponseFormat.Text, "json_object" => ChatResponseFormat.Json, - JsonElement e => ChatResponseFormat.ForJsonSchema(e.ToString()), + JsonElement e => ChatResponseFormat.ForJsonSchema(e), _ => null, }; } diff --git a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs index ba9d4e80fc80..308dbc64e183 100644 --- a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs +++ b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs @@ -155,8 +155,8 @@ public void Dispose() } else if (options.ResponseFormat is ChatResponseFormatJson json) { - settings.ExtensionData["response_format"] = json.Schema is not null ? - JsonSerializer.Deserialize(json.Schema, AbstractionsJsonContext.Default.JsonElement) : + settings.ExtensionData["response_format"] = json.Schema is JsonElement schema ? + JsonSerializer.Deserialize(schema, AbstractionsJsonContext.Default.JsonElement) : "json_object"; } } diff --git a/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs b/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs index 9f8a60b40098..cce73a65510f 100644 --- a/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs @@ -256,9 +256,9 @@ public async Task AsChatClientNonStreamingResponseFormatHandled() oaiSettings = JsonSerializer.Deserialize(JsonSerializer.Serialize(actualSettings)); Assert.Equal("json_object", oaiSettings?.ResponseFormat?.ToString()); - await client.CompleteAsync(messages, new() { ResponseFormat = ChatResponseFormat.ForJsonSchema(""" + await client.CompleteAsync(messages, new() { ResponseFormat = ChatResponseFormat.ForJsonSchema(JsonSerializer.Deserialize(""" {"type": "string"} - """) }); + """)) }); oaiSettings = JsonSerializer.Deserialize(JsonSerializer.Serialize(actualSettings)); Assert.Equal(JsonValueKind.Object, Assert.IsType(oaiSettings?.ResponseFormat).ValueKind); }