Merge branch 'SciSharp:master' into master

This commit is contained in:
hchen2020 2025-01-16 15:58:08 -06:00 committed by GitHub
commit 133e5f28bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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