refine gemini function parameter
This commit is contained in:
parent
48eb6e8fda
commit
90c2bd75df
|
|
@ -126,18 +126,19 @@ public class GeminiChatCompletionProvider : IChatCompletion
|
||||||
if (!agentService.RenderFunction(agent, function)) continue;
|
if (!agentService.RenderFunction(agent, function)) continue;
|
||||||
|
|
||||||
var def = agentService.RenderFunctionProperty(agent, function);
|
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
|
funcDeclarations.Add(new FunctionDeclaration
|
||||||
{
|
{
|
||||||
Name = function.Name,
|
Name = function.Name,
|
||||||
Description = function.Description,
|
Description = function.Description,
|
||||||
Parameters = str != "{}" ? new()
|
Parameters = parameters
|
||||||
{
|
|
||||||
Type = ParameterType.Object,
|
|
||||||
Properties = JsonSerializer.Deserialize<dynamic>(str),
|
|
||||||
Required = def?.Required ?? []
|
|
||||||
} : null
|
|
||||||
});
|
});
|
||||||
|
|
||||||
funcPrompts.Add($"{function.Name}: {function.Description} {def}");
|
funcPrompts.Add($"{function.Name}: {function.Description} {def}");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue