Skip to content

Commit

Permalink
fix: fix skylark function calling format error
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Mar 13, 2024
1 parent b067d63 commit 4f4bc15
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions adapter/skylark/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion globals/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down

0 comments on commit 4f4bc15

Please sign in to comment.