ExecuteToolWithoutContext 不使用 ToolContext 执行工具(用于测试不依赖 sandbox 的工具)
(t *testing.T, tool tools.Tool, input map[string]any)
| 174 | |
| 175 | // ExecuteToolWithoutContext 不使用 ToolContext 执行工具(用于测试不依赖 sandbox 的工具) |
| 176 | func ExecuteToolWithoutContext(t *testing.T, tool tools.Tool, input map[string]any) map[string]any { |
| 177 | ctx := context.Background() |
| 178 | |
| 179 | result, err := tool.Execute(ctx, input, nil) |
| 180 | if err != nil { |
| 181 | t.Fatalf("Tool execution failed: %v", err) |
| 182 | } |
| 183 | |
| 184 | // 将result转换为map[string]any |
| 185 | if resultMap, ok := result.(map[string]any); ok { |
| 186 | return resultMap |
| 187 | } |
| 188 | |
| 189 | t.Fatalf("Expected map[string]any result, got %T", result) |
| 190 | return nil |
| 191 | } |
| 192 | |
| 193 | // CustomWorkDirSandbox 自定义工作目录的沙箱(仅用于测试) |
| 194 | type CustomWorkDirSandbox struct { |