.Net: CreatePlanAsync() is throwing a JsonReaderException
I am getting a JsonReader exception on creating a plan - have tried with both ActionPlanner and SequentialPlanner.
Tested with Microsoft.SemanticKernel version 1.0.0-beta3
This is the code snippet:
var planner = new ActionPlanner(kernel); var plan = await planner.CreatePlanAsync(goal);
And here is the exception info:
Microsoft.SemanticKernel.Diagnostics.SKException: 'Plan parsing error, invalid JSON'
Microsoft.SemanticKernel.Diagnostics.SKException
HResult=0x80131500
Message=Plan parsing error, invalid JSON
Source=Microsoft.SemanticKernel.Planners.Core
StackTrace:
at Microsoft.SemanticKernel.Planners.ActionPlanner.ParsePlannerResult(FunctionResult plannerResult)
at Microsoft.SemanticKernel.Planners.ActionPlanner.
Inner Exception 1: JsonException: '{' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
Inner Exception 2: JsonReaderException: '{' is an invalid start of a property name. Expected a '"'. LineNumber: 0 | BytePositionInLine: 1.
This can happen when the planner returns back invalid JSON (which can happen because the LLM isn't always perfect). We recommend improving the descriptions of your plugins and adding a try/catch whenever you create a new plan so that you can recover from an error like this.
Okay, thanks for the update. I will try to make it work.
Fyi - this is the example I was referring to, with some edits for adding description for input:
https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/planners/?tabs=Csharp
[SKFunction, Description("Given a number, take the square root of that number")]
public double Sqrt(
[Description("The input number for which square root is to be calculated.")] double input)
{
return System.Math.Sqrt(input);
}
Update: For the same plugin -
- Stepwise Planner works
- Sequential Planner fails to make a plan
- Action Planner throws the Json exception reported above
@matthewbolanos - Am hitting this error sporadically with same prompt and same input but at different times. Is there a way to expose JSON somewhere so that there is a better idea to fix the problem?
@matthewbolanos - Am hitting this error sporadically with same prompt and same input but at different times. Is there a way to expose JSON somewhere so that there is a better idea to fix the problem?
I am facing similar issue
These planners have been deprecated. Are you able to share what version of Semantic Kernel you are using?
I use 0.4.5.dev0 and even tried 0.5.1.dev0 versions both had plannera in them . So are all planners deprecated?
On Wed, Feb 28, 2024, 3:03 AM Matthew Bolaños @.***> wrote:
These planners have been deprecated. Are you able to share what version of Semantic Kernel you are using?
— Reply to this email directly, view it on GitHub https://github.com/microsoft/semantic-kernel/issues/3289#issuecomment-1968742128, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJCCK6RMXTGXVWIFAABC2G3YV4FG5AVCNFSM6AAAAAA6OX7ADGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYG42DEMJSHA . You are receiving this because you commented.Message ID: @.***>