NewCodeExecuteTool 创建代码执行工具
(config map[string]any)
| 26 | |
| 27 | // NewCodeExecuteTool 创建代码执行工具 |
| 28 | func NewCodeExecuteTool(config map[string]any) (tools.Tool, error) { |
| 29 | runtimeConfig := bridge.DefaultRuntimeConfig() |
| 30 | |
| 31 | // 解析配置 |
| 32 | if timeout, ok := config["timeout"].(float64); ok { |
| 33 | runtimeConfig.Timeout = time.Duration(timeout) * time.Second |
| 34 | } |
| 35 | if workDir, ok := config["work_dir"].(string); ok { |
| 36 | runtimeConfig.WorkDir = workDir |
| 37 | } |
| 38 | |
| 39 | return &CodeExecuteTool{ |
| 40 | runtimeManager: bridge.NewRuntimeManager(runtimeConfig), |
| 41 | }, nil |
| 42 | } |
| 43 | |
| 44 | // NewCodeExecuteToolWithBridge 创建带桥接器的代码执行工具 |
| 45 | func NewCodeExecuteToolWithBridge(toolBridge *bridge.ToolBridge) *CodeExecuteTool { |
nothing calls this directly
no test coverage detected