MicrosoftDocs / semantic-kernel-docs

Semantic Kernel (SK) is a lightweight SDK enabling integration of AI Large Language Models (LLMs) with conventional programming languages.
MIT License
173 stars 100 forks source link

OrchestratorPlugin class would crash when the intent is "Multiply" #54

Open sramaswami11 opened 8 months ago

sramaswami11 commented 8 months ago

Please refer to the following doc page: https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/plugins/native-functions/calling-nested-functions?tabs=Csharp

The csharp code under this page (in the Putting it all together section) as well as in the github code orchestrator.cs will cause the application to crash due to an iinvalid cast exception when the intent evaluates to "Multiply"

Here are the details: System.InvalidCastException HResult=0x80004002 Message=Cannot cast System.String to System.Double Source=Microsoft.SemanticKernel.Abstractions StackTrace: at Microsoft.SemanticKernel.Orchestration.KernelResult.GetValue[T]() at SKPrompts.Plugins.OrchestratorPlugin.Orchestrator.d2.MoveNext() in C:\Siva\Projects\SemanticKernel\SKPrompts\SKPrompts\Plugins\OrchestratorPlugin\OrchestratorPlugin.cs:line 61 at Microsoft.SemanticKernel.NativeFunction.<>c.<b35_7>d.MoveNext() at Microsoft.SemanticKernel.NativeFunction.d18.MoveNext() at Microsoft.SemanticKernel.Kernel.d21.MoveNext() at Program.<

$>d__0.MoveNext() in C:\XXX\Program.cs:line 48

The code that causes this exception is in Orchestrator.cs line#58 return result.GetValue()!.ToString();

This line needs to be changed to return result.GetValue()!.ToString(); //same as line#48

crickman commented 8 months ago

Thank you, I suspect this is related to the rapid SK march thru beta towards release (currently beta-3: https://github.com/microsoft/semantic-kernel/releases/tag/dotnet-1.0.0-beta3)

I'll see if we can't get some hygiene scheduled.