MCPcopy Index your code
hub / github.com/docker/docker-agent / parseToolCall

Function parseToolCall

pkg/evaluation/save.go:281–301  ·  view source on GitHub ↗

parseToolCall converts a map representation of a tool call to tools.ToolCall

(tc map[string]any)

Source from the content-addressed store, hash-verified

279
280// parseToolCall converts a map representation of a tool call to tools.ToolCall
281func 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
304func parseToolDefinition(td map[string]any) tools.Tool {

Callers 2

SessionFromEventsFunction · 0.85
TestParseToolCallFunction · 0.85

Calls 1

ToolTypeTypeAlias · 0.92

Tested by 1

TestParseToolCallFunction · 0.68