I'm trying to follow Microsoft's example for calling a native plugin, albeit in a LinqPad script.
The Pluging I've added to my script is identical to the example here.
When I call it "directly" using the following code, it works just fine:
double resultDirect = await kernel.InvokeAsync<double>(
nameof(Plugins.MathPlugin), nameof(Plugins.MathPlugin.Sqrt),
new()
{
{"number1", 12 },
})!;
resultDirect.Dump();
However...when following the example Allow the AI to automatically call your function then the following line throws an exception:
await foreach (var content in result)
I get a Microsoft.SemanticKernel.HttpOperatonException
thrown:
Unrecognized request arguments supplied: tool_choice, tools Status: 400 (model_error)
Content:
{
"error": {
"message": "Unrecognized request arguments supplied: tool_choice, tools",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
I'm consuming the following NuGet packages:
Microsft.SemanticKernel 1.1.0
Microsft.SemanticKernel.Plugins.Core(pre) 1.1.0-alpha
Microsft.SemanticKernel.Planners.Handlebars(pre) 1.1.0-preview
The "tools" and "tool_choice" are relative new addition to OpenAI api which might not be avaliable in the model you were using. Try a later version model and it should work.
To confirm, I tested with the exact same version of NuGet packages and followed the same code example. Only difference was that I was using Azure OpenAI GPT-3.5-turbo-1106 and GPT-4-1106-Preview as AI service. Both worked well.
Here is the polygon notebook code: