diff --git a/adapter/skylark/formatter.go b/adapter/skylark/formatter.go index 191f9fe..6e3cab3 100644 --- a/adapter/skylark/formatter.go +++ b/adapter/skylark/formatter.go @@ -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": diff --git a/globals/tools.go b/globals/tools.go index de941e0..364964f 100644 --- a/globals/tools.go +++ b/globals/tools.go @@ -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"`