MicrosoftDocs / semantic-kernel-docs

Semantic Kernel (SK) is a lightweight SDK enabling integration of AI Large Language Models (LLMs) with conventional programming languages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OrchestratorPlugin class would crash when the intent is "Multiply"

sramaswami11 opened this issue · comments

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.GetValueT
at SKPrompts.Plugins.OrchestratorPlugin.Orchestrator.d__2.MoveNext() in C:\Siva\Projects\SemanticKernel\SKPrompts\SKPrompts\Plugins\OrchestratorPlugin\OrchestratorPlugin.cs:line 61
at Microsoft.SemanticKernel.NativeFunction.<>c.<b__35_7>d.MoveNext()
at Microsoft.SemanticKernel.NativeFunction.d__18.MoveNext()
at Microsoft.SemanticKernel.Kernel.d__21.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

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.