CallToolJSON 使用 JSON 字符串调用工具
(ctx context.Context, name string, inputJSON string, tc *tools.ToolContext)
| 88 | |
| 89 | // CallToolJSON 使用 JSON 字符串调用工具 |
| 90 | func (b *ToolBridge) CallToolJSON(ctx context.Context, name string, inputJSON string, tc *tools.ToolContext) (*CallToolResult, error) { |
| 91 | var input map[string]any |
| 92 | if err := json.Unmarshal([]byte(inputJSON), &input); err != nil { |
| 93 | return &CallToolResult{ |
| 94 | Name: name, |
| 95 | Success: false, |
| 96 | Error: fmt.Sprintf("invalid JSON input: %v", err), |
| 97 | }, nil |
| 98 | } |
| 99 | |
| 100 | return b.CallTool(ctx, name, input, tc) |
| 101 | } |
| 102 | |
| 103 | // BatchCallResult 批量调用结果 |
| 104 | type BatchCallResult struct { |