Add tool requires approval
This commit is contained in:
@@ -238,6 +238,9 @@ type ToolConfig struct {
|
||||
Parameters map[string]any `yaml:"parameters"`
|
||||
// Timeout limits execution time (e.g., "30s", "5m"). Zero means no limit.
|
||||
Timeout time.Duration `yaml:"timeout"`
|
||||
// RequiresApproval specifies whether a tool must be approved by a user
|
||||
// to execute.
|
||||
RequiresApproval bool `yaml:"require_approval,omitempty"`
|
||||
}
|
||||
|
||||
func (cfg ToolConfig) Validate() error {
|
||||
|
||||
@@ -386,6 +386,50 @@ tools:
|
||||
cfg.Tools[0].Name, "echo",
|
||||
)
|
||||
}
|
||||
if cfg.Tools[0].RequiresApproval {
|
||||
t.Error("Tools[0].RequiresApproval = true, want false")
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "tool with require_approval",
|
||||
config: `
|
||||
database:
|
||||
path: "/tmp/odidere-test.db"
|
||||
|
||||
default_model:
|
||||
provider: testprovider
|
||||
model: test-model
|
||||
|
||||
providers:
|
||||
- name: testprovider
|
||||
url: http://localhost:8080
|
||||
|
||||
stt:
|
||||
url: http://localhost:8178
|
||||
|
||||
tts:
|
||||
url: http://localhost:8880
|
||||
voice: af_heart
|
||||
|
||||
tools:
|
||||
- name: echo
|
||||
description: echoes input
|
||||
command: echo
|
||||
arguments:
|
||||
- "{{.message}}"
|
||||
require_approval: true
|
||||
`,
|
||||
check: func(t *testing.T, cfg *Config) {
|
||||
if len(cfg.Tools) != 1 {
|
||||
t.Errorf(
|
||||
"len(Tools) = %d, want 1",
|
||||
len(cfg.Tools),
|
||||
)
|
||||
}
|
||||
if !cfg.Tools[0].RequiresApproval {
|
||||
t.Error("Tools[0].RequiresApproval = false, want true")
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user