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 @@ <PackageVersion Include="Microsoft.DeepDev.TokenizerLib" Version="1.3.3" /> <PackageVersion Include="SharpToken" Version="2.0.3" /> <!-- Microsoft.Extensions.* --> - <PackageVersion Include="Microsoft.Extensions.AI" Version="9.0.1-preview.1.24570.5" /> - <PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5" /> - <PackageVersion Include="Microsoft.Extensions.AI.AzureAIInference" Version="9.0.1-preview.1.24570.5" /> + <PackageVersion Include="Microsoft.Extensions.AI" Version="9.1.0-preview.1.25064.3" /> + <PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.1.0-preview.1.25064.3" /> + <PackageVersion Include="Microsoft.Extensions.AI.AzureAIInference" Version="9.1.0-preview.1.25064.3" /> <PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" /> <PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" /> 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<StreamingChatMessageContent> 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<OpenAIPromptExecutionSettings>(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<JsonElement>(""" {"type": "string"} - """) }); + """)) }); oaiSettings = JsonSerializer.Deserialize<OpenAIPromptExecutionSettings>(JsonSerializer.Serialize(actualSettings)); Assert.Equal(JsonValueKind.Object, Assert.IsType<JsonElement>(oaiSettings?.ResponseFormat).ValueKind); }