fix gemini function call

This commit is contained in:
Jicheng Lu 2025-01-15 15:40:35 -06:00
parent ccb31f5cd8
commit 48eb6e8fda

View file

@ -126,18 +126,18 @@ public class GeminiChatCompletionProvider : IChatCompletion
if (!agentService.RenderFunction(agent, function)) continue;
var def = agentService.RenderFunctionProperty(agent, function);
var str = JsonSerializer.Serialize(def.Properties);
var str = JsonSerializer.Serialize(def?.Properties);
funcDeclarations.Add(new FunctionDeclaration
{
Name = function.Name,
Description = function.Description,
Parameters = new()
Parameters = str != "{}" ? new()
{
Type = str != "{}" ? ParameterType.Object : ParameterType.TypeUnspecified,
Properties = str != "{}" ? JsonSerializer.Deserialize<dynamic>(str) : null,
Required = def.Required
}
Type = ParameterType.Object,
Properties = JsonSerializer.Deserialize<dynamic>(str),
Required = def?.Required ?? []
} : null
});
funcPrompts.Add($"{function.Name}: {function.Description} {def}");