microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.94k stars 3.27k forks source link

Bug: Ollama connector fails when calling plugin functions that have parameters with Guid type #9711

Open nitrovent opened 5 hours ago

nitrovent commented 5 hours ago

Describe the bug Function call fails when trying to call function that has guid parameter:

fail: Microsoft.SemanticKernel.KernelFunction[0]
      Function TodoPlugin-SetCompleted failed. Error: No converter found to convert from System.Guid to System.Text.Json.JsonElement. (Parameter 'id')
      Actual value was 9416a630-d9ca-45d0-bf02-3f8d0d3e17bb.
      System.ArgumentOutOfRangeException: No converter found to convert from System.Guid to System.Text.Json.JsonElement. (Parameter 'id')
      Actual value was 9416a630-d9ca-45d0-bf02-3f8d0d3e17bb.
         at Microsoft.SemanticKernel.KernelFunctionFromMethod.<>c__DisplayClass22_0.<GetParameterMarshalerDelegate>g__Process|10(Object value, <>c__DisplayClass22_1&)
         at Microsoft.SemanticKernel.KernelFunctionFromMethod.<>c__DisplayClass22_0.<GetParameterMarshalerDelegate>g__parameterFunc|9(KernelFunction _, Kernel kernel, KernelArguments arguments, CancellationToken __)
         at Microsoft.SemanticKernel.KernelFunctionFromMethod.<>c__DisplayClass20_0.<GetMethodDetails>g__Function|0(Kernel kernel, KernelFunction function, KernelArguments arguments, CancellationToken cancellationToken)
         at Microsoft.SemanticKernel.KernelFunctionFromMethod.InvokeCoreAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)
         at Microsoft.SemanticKernel.KernelFunction.<>c__DisplayClass27_0.<<InvokeAsync>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at Microsoft.SemanticKernel.Kernel.InvokeFilterOrFunctionAsync(NonNullCollection`1 functionFilters, Func`2 functionCallback, FunctionInvocationContext context, Int32 index)
         at Microsoft.SemanticKernel.Kernel.OnFunctionInvocationAsync(KernelFunction function, KernelArguments arguments, FunctionResult functionResult, Boolean isStreaming, Func`2 functionCallback, CancellationToken cancellationToken)
         at Microsoft.SemanticKernel.KernelFunction.InvokeAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)

To Reproduce Steps to reproduce the behavior:

  1. Add plugin with function with guid parameter, in my case:
    [KernelFunction, Description("Set the completed state of a todo")]
    public void SetCompleted(
    [Description("Determines the id of the todo to toggle")] Guid id, 
    [Description("Determines whether to to complete or to resume the todo")] bool complete = true) 
    { 
    //...
    }
  2. Give instructions that will call the function

Expected behavior Function calls work with functions with guid parameters

Platform

Additional context Works well with the Azure connector.

nitrovent commented 5 hours ago

Edit because I thought I it was with a boolean parameter. I am sure I saw that error for boolean, too when testing.