Added a configurable timeout knob
This commit is contained in:
@@ -107,6 +107,9 @@ func validateProfile(p *domain.PromptProfile) error {
|
||||
if p.Validation.ValidationMode == domain.ValidationJSONSchema && strings.TrimSpace(p.Validation.SchemaPath) == "" {
|
||||
return errors.New("validation.schema_path is required when validation_mode is json_schema")
|
||||
}
|
||||
if p.ModelDefaults.TimeoutSeconds < 0 {
|
||||
return errors.New("model_defaults.timeout_seconds must be greater than or equal to 0")
|
||||
}
|
||||
if p.Validation.Format != "" && p.Validation.Format != p.OutputFormat {
|
||||
return fmt.Errorf("validation format %q does not match output format %q", p.Validation.Format, p.OutputFormat)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@ func TestFilesystemRepository_GetProfile(t *testing.T) {
|
||||
if p.Validation.ValidationMode != domain.ValidationBasic {
|
||||
t.Fatalf("expected validation mode basic, got %q", p.Validation.ValidationMode)
|
||||
}
|
||||
if p.ModelDefaults.TimeoutSeconds != 120 {
|
||||
t.Fatalf("expected timeout_seconds 120, got %d", p.ModelDefaults.TimeoutSeconds)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("invalid YAML", func(t *testing.T) {
|
||||
@@ -94,6 +97,13 @@ func TestFilesystemRepository_GetProfile(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("negative timeout seconds", func(t *testing.T) {
|
||||
_, err := repo.GetProfile(ctx, "negative-timeout", "")
|
||||
if !errors.Is(err, ErrInvalidProfile) {
|
||||
t.Errorf("expected ErrInvalidProfile for negative timeout_seconds, got %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("profile not found", func(t *testing.T) {
|
||||
_, err := repo.GetProfile(ctx, "unknown", "")
|
||||
if !errors.Is(err, ErrProfileNotFound) {
|
||||
|
||||
10
internal/profile/testdata/negative_timeout.yaml
vendored
Normal file
10
internal/profile/testdata/negative_timeout.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
id: negative-timeout
|
||||
version: "1.0.0"
|
||||
templates:
|
||||
- role: user
|
||||
content: "Say hi"
|
||||
model_defaults:
|
||||
timeout_seconds: -1
|
||||
output_format: text
|
||||
validation:
|
||||
validation_mode: none
|
||||
1
internal/profile/testdata/valid.yaml
vendored
1
internal/profile/testdata/valid.yaml
vendored
@@ -12,6 +12,7 @@ templates:
|
||||
model_defaults:
|
||||
model: gpt-4o
|
||||
temperature: 0.7
|
||||
timeout_seconds: 120
|
||||
output_format: markdown
|
||||
validation:
|
||||
validation_mode: basic
|
||||
|
||||
Reference in New Issue
Block a user