parseToolDefinition converts a map representation of a tool definition to tools.Tool
(td map[string]any)
| 302 | |
| 303 | // parseToolDefinition converts a map representation of a tool definition to tools.Tool |
| 304 | func parseToolDefinition(td map[string]any) tools.Tool { |
| 305 | toolDef := tools.Tool{} |
| 306 | |
| 307 | if name, ok := td["name"].(string); ok { |
| 308 | toolDef.Name = name |
| 309 | } |
| 310 | if category, ok := td["category"].(string); ok { |
| 311 | toolDef.Category = category |
| 312 | } |
| 313 | if description, ok := td["description"].(string); ok { |
| 314 | toolDef.Description = description |
| 315 | } |
| 316 | if parameters, ok := td["parameters"]; ok { |
| 317 | toolDef.Parameters = parameters |
| 318 | } |
| 319 | |
| 320 | return toolDef |
| 321 | } |
| 322 | |
| 323 | // parseMessageUsage converts a map representation of message usage to chat.Usage |
| 324 | // Note: The embedded chat.Usage fields use snake_case JSON tags (input_tokens, etc.) |
no outgoing calls