added anthropic tool support i think

This commit is contained in:
2025-04-12 03:41:48 -04:00
parent 3093b988f8
commit 916f07be18
7 changed files with 79 additions and 27 deletions

View File

@@ -98,6 +98,29 @@ func (o Object) GoogleParameters() *genai.Schema {
return res
}
func (o Object) AnthropicInputSchema() map[string]any {
var properties = map[string]any{}
var required []string
for k, v := range o.fields {
properties[k] = v.AnthropicInputSchema()
if v.Required() {
required = append(required, k)
}
}
var res = map[string]any{
"type": "object",
"description": o.Description(),
"properties": properties,
}
if len(required) > 0 {
res["required"] = required
}
return res
}
// FromAny converts the value from any to the correct type, returning the value, and an error if any
func (o Object) FromAny(val any) (reflect.Value, error) {
// if the value is nil, we can't do anything