You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Boolean model parameters are deserialised as string values. This causes an exception on calling OpenAIPromptExecutionSettings.FromExecutionSettings
To Reproduce
Steps to reproduce the behavior:
Create a dotnet console app
Add references to Microsoft.SemanticKernel 1.44.0, Microsoft.SemanticKernel.Prompty 1.44.0-alpha
Program.cs:
usingMicrosoft.SemanticKernel;usingMicrosoft.SemanticKernel.Connectors.OpenAI;
#pragma warning disable SKEXP0010,SKEXP0040// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.varkernel=newKernel();varkernelFunction=kernel.CreateFunctionFromPrompty(""" --- name: SomePrompt description: This is the description. model: api: chat configuration: type: azure_openai_beta parameters: logprobs: true --- Abc---def """);PromptExecutionSettingssettings=kernelFunction.ExecutionSettings!["default"];Console.WriteLine(settings.ExtensionData!["logprobs"].GetType());// shows System.String but should be System.BooleanvarexecutionSettings=OpenAIPromptExecutionSettings.FromExecutionSettings(settings);// throws exceptionConsole.WriteLine(executionSettings.Logprobs);
Expected behavior
Program runs without exception and outputs correct value of LogProbs property.
Actual behavior
Throws exception
System.Text.Json.JsonException
HResult=0x80131500
Message=The JSON value could not be converted to System.Nullable`1[System.Boolean]. Path: $.logprobs | LineNumber: 0 | BytePositionInLine: 84.
Source=System.Text.Json
StackTrace:
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at Microsoft.SemanticKernel.Connectors.OpenAI.OpenAIPromptExecutionSettings.FromExecutionSettings(PromptExecutionSettings executionSettings, Nullable`1 defaultMaxTokens)
at Program.<Main>$(String[] args) in C:\Users\Developer\source\repos\ConsoleApp4\Program.cs:line 26
This exception was originally thrown at this call stack:
System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedBoolean(System.Text.Json.JsonTokenType)
System.Text.Json.Utf8JsonReader.GetBoolean()
System.Text.Json.Serialization.Converters.NullableConverter<T>.Read(ref System.Text.Json.Utf8JsonReader, System.Type, System.Text.Json.JsonSerializerOptions)
System.Text.Json.Serialization.Metadata.JsonPropertyInfo<T>.ReadJsonAndSetMember(object, ref System.Text.Json.ReadStack, ref System.Text.Json.Utf8JsonReader)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<T>.OnTryRead(ref System.Text.Json.Utf8JsonReader, System.Type, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack, out T)
System.Text.Json.Serialization.JsonConverter<T>.TryRead(ref System.Text.Json.Utf8JsonReader, System.Type, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack, out T, out bool)
System.Text.Json.Serialization.JsonConverter<T>.ReadCore(ref System.Text.Json.Utf8JsonReader, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack)
Inner Exception 1:
InvalidOperationException: Cannot get the value of a token type 'String' as a boolean.
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Bug: CreateFunctionFromPrompty does not deserialise boolean parameter values correctly
.Net: Bug: CreateFunctionFromPrompty does not deserialise boolean parameter values correctly
Apr 1, 2025
Describe the bug
Boolean model parameters are deserialised as string values. This causes an exception on calling
OpenAIPromptExecutionSettings.FromExecutionSettings
To Reproduce
Steps to reproduce the behavior:
Microsoft.SemanticKernel
1.44.0,Microsoft.SemanticKernel.Prompty
1.44.0-alphaExpected behavior
Program runs without exception and outputs correct value of
LogProbs
property.Actual behavior
Throws exception
The text was updated successfully, but these errors were encountered: