You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When a class with a nullable property (e.g. string? Location) is used as an input parameter to a plugin method in a Gemini LLM function call, a 400 error is returned from the Gemini API. This error does not occur when the same property is defined as non-nullable (string Location).
To Reproduce
Steps to reproduce the behavior:
Define a plugin method that accepts a class with a nullable string property string? Location.
Register the plugin with Semantic Kernel
Invoke a prompt using GeminiPromptExecutionSettings with ToolCallBehavior = AutoInvokeKernelFunctions.
Observe that the Gemini API returns a 400 error.
{
"name": "Plugin_GetWeather",
"description": "Get the weather for a given location.",
"parameters": {
"type": "object",
"required": ["request"],
"properties": {
"request": {
"type": "object",
"properties": {
"Location": {
"type": ["string", "null"]
}
}
}
}
}
}
Expected behavior
The function should be successfully invoked, and Gemini should handle nullable fields in the schema without returning an error.
The issue is caused by the type definition "type": ["string", "null"]
varkernelBuilder=Kernel.CreateBuilder().AddGoogleAIGeminiChatCompletion(modelId:"gemini-2.0-flash",apiKey:apiKey);kernelBuilder.Plugins.AddFromType<Plugin>();varpromptExecutionSettings=newGeminiPromptExecutionSettings(){ToolCallBehavior=GeminiToolCallBehavior.AutoInvokeKernelFunctions,};varkernel=kernelBuilder.Build();varresponse=awaitkernel.InvokePromptAsync("Hi, what's the weather in New York?",new(promptExecutionSettings));Console.WriteLine(response.ToString());classPlugin{[KernelFunction][Description("Get the weather for a given location.")]stringGetWeather(Requestrequest){return$"The weather in {request?.Location} is sunny.";}}classRequest{publicstring?Location{get;set;}}
The text was updated successfully, but these errors were encountered:
Describe the bug
When a class with a nullable property (e.g.
string? Location
) is used as an input parameter to a plugin method in a Gemini LLM function call, a 400 error is returned from the Gemini API. This error does not occur when the same property is defined as non-nullable (string Location
).To Reproduce
Steps to reproduce the behavior:
string? Location
.GeminiPromptExecutionSettings
withToolCallBehavior = AutoInvokeKernelFunctions
.Expected behavior
The function should be successfully invoked, and Gemini should handle nullable fields in the schema without returning an error.
The issue is caused by the type definition
"type": ["string", "null"]
Screenshots
N/A
Platform
Additional context
The text was updated successfully, but these errors were encountered: