fix: fix skylark function calling format error

This commit is contained in:
Zhang Minghan 2024-03-13 09:30:16 +08:00
parent b067d63012
commit 4f4bc1561b
2 changed files with 19 additions and 3 deletions

View File

@ -19,10 +19,26 @@ func getFunctionCall(calls *globals.ToolCalls) *api.FunctionCall {
}
}
func getType(p globals.ToolProperty) string {
if p.Type == nil {
return "string"
}
return *p.Type
}
func getDescription(p globals.ToolProperty) string {
if p.Description == nil {
return ""
}
return *p.Description
}
func getValue(p globals.ToolProperty) *structpb.Value {
switch p.Type {
switch getType(p) {
case "string", "enum":
return &structpb.Value{Kind: &structpb.Value_StringValue{StringValue: p.Description}}
return &structpb.Value{Kind: &structpb.Value_StringValue{StringValue: getDescription(p)}}
case "number":
return &structpb.Value{Kind: &structpb.Value_NumberValue{NumberValue: 0}}
case "boolean":

View File

@ -26,7 +26,7 @@ type ToolProperties map[string]ToolProperty
type JsonSchemaType any
type JSONSchemaDefinition any
type ToolProperty struct {
Type *JsonSchemaType `json:"type,omitempty"`
Type *string `json:"type,omitempty"`
Enum *[]JsonSchemaType `json:"enum,omitempty"`
Const *JsonSchemaType `json:"const,omitempty"`