parseToolCall converts a map representation of a tool call to tools.ToolCall
(tc map[string]any)
| 279 | |
| 280 | // parseToolCall converts a map representation of a tool call to tools.ToolCall |
| 281 | func parseToolCall(tc map[string]any) tools.ToolCall { |
| 282 | toolCall := tools.ToolCall{} |
| 283 | |
| 284 | if id, ok := tc["id"].(string); ok { |
| 285 | toolCall.ID = id |
| 286 | } |
| 287 | if typ, ok := tc["type"].(string); ok { |
| 288 | toolCall.Type = tools.ToolType(typ) |
| 289 | } |
| 290 | |
| 291 | if fn, ok := tc["function"].(map[string]any); ok { |
| 292 | if name, ok := fn["name"].(string); ok { |
| 293 | toolCall.Function.Name = name |
| 294 | } |
| 295 | if args, ok := fn["arguments"].(string); ok { |
| 296 | toolCall.Function.Arguments = args |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return toolCall |
| 301 | } |
| 302 | |
| 303 | // parseToolDefinition converts a map representation of a tool definition to tools.Tool |
| 304 | func parseToolDefinition(td map[string]any) tools.Tool { |