Resolve pipeline settings and collection selections
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultModulesCSV = "glossary,homophones,glossary,spoken_word,grammar"
|
||||
DefaultTranscriptDescriptionMaxChars = 500
|
||||
DefaultValidationMaxPromptTokens = 2048
|
||||
)
|
||||
@@ -142,6 +141,7 @@ func Load(input ck.Input, overlay string, overrides ...ck.Override) (*ck.Result[
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
Resolve: resolveSettings,
|
||||
Validate: validate,
|
||||
},
|
||||
})
|
||||
@@ -168,8 +168,33 @@ func validate(c *Config, v *ck.Validation) {
|
||||
check(c.LLM.TransientRetries >= 0, ck.Keys("llm", "transient_retries"), "retry budget must be non-negative")
|
||||
check(c.LLM.RepairAttempts >= 0 && c.LLM.RepairAttempts <= 3, ck.Keys("llm", "repair_attempts"), "repair attempts must be between zero and three")
|
||||
check(c.LLM.OperationTimeout > 0, ck.Keys("llm", "operation_timeout"), "operation timeout must be positive")
|
||||
for i, stage := range c.Pipeline.Stages {
|
||||
check(modulecatalog.IsSupported(stage.Module), ck.Keys("pipeline", "stages").Index(i).Key("module"), "unsupported module key")
|
||||
check(c.LLM.ValidationProfile == nil || *c.LLM.ValidationProfile != "", ck.Keys("llm", "validation_profile"), "validation profile must not be empty; use null to clear it")
|
||||
validateSelections := func(values []string, path ck.Path) {
|
||||
for i, name := range values {
|
||||
_, exists := c.GlossaryCollections[name]
|
||||
check(exists, path.Index(i), "unknown glossary collection")
|
||||
}
|
||||
}
|
||||
validateSelections(c.Glossaries, ck.Keys("glossaries"))
|
||||
validateSelections(c.ProtectedTerms, ck.Keys("protected_terms"))
|
||||
ids := make(map[string]bool)
|
||||
for i, item := range c.Pipeline.Stages {
|
||||
path := ck.Keys("pipeline", "stages").Index(i)
|
||||
check(modulecatalog.IsSupported(item.Module), path.Key("module"), "unsupported module key")
|
||||
if item.ID != nil {
|
||||
check(*item.ID != "", path.Key("id"), "id must not be empty")
|
||||
check(!ids[*item.ID], path.Key("id"), "id must be unique")
|
||||
ids[*item.ID] = true
|
||||
}
|
||||
validateSelections(item.Glossaries, path.Key("glossaries"))
|
||||
validateSelections(item.ProtectedTerms, path.Key("protected_terms"))
|
||||
check(item.ConfidenceThreshold >= 0 && item.ConfidenceThreshold <= 1, path.Key("confidence_threshold"), "confidence threshold must be between zero and one")
|
||||
check(item.LLM.ValidationProfile == nil || *item.LLM.ValidationProfile != "", path.Key("llm").Key("validation_profile"), "validation profile must not be empty; use null to clear it")
|
||||
check(item.LLM.TransientRetries >= 0, path.Key("llm").Key("transient_retries"), "retry budget must be non-negative")
|
||||
check(item.LLM.RepairAttempts >= 0 && item.LLM.RepairAttempts <= 3, path.Key("llm").Key("repair_attempts"), "repair attempts must be between zero and three")
|
||||
check(item.LLM.OperationTimeout > 0, path.Key("llm").Key("operation_timeout"), "operation timeout must be positive")
|
||||
check(item.Validation.MaxPromptTokens > 0, path.Key("validation").Key("max_prompt_tokens"), "validation prompt budget must be positive")
|
||||
check(len(strings.TrimSpace(item.Context.Description)) <= DefaultTranscriptDescriptionMaxChars, path.Key("context").Key("description"), fmt.Sprintf("description must be at most %d bytes after trimming", DefaultTranscriptDescriptionMaxChars))
|
||||
}
|
||||
check(outputschema.IsSupported(c.Output.Schema), ck.Keys("output", "schema"), "unsupported output schema")
|
||||
check(c.Validation.MaxPromptTokens > 0, ck.Keys("validation", "max_prompt_tokens"), "validation prompt budget must be positive")
|
||||
@@ -185,18 +210,3 @@ func validate(c *Config, v *ck.Validation) {
|
||||
}
|
||||
check(len(strings.TrimSpace(c.Context.Description)) <= DefaultTranscriptDescriptionMaxChars, ck.Keys("context", "description"), fmt.Sprintf("description must be at most %d bytes after trimming", DefaultTranscriptDescriptionMaxChars))
|
||||
}
|
||||
|
||||
// ParseModulesCSV is used only for an explicitly supplied --modules override.
|
||||
func ParseModulesCSV(raw string) ([]string, error) {
|
||||
if raw == "" {
|
||||
return []string{}, nil
|
||||
}
|
||||
parts := strings.Split(raw, ",")
|
||||
for i := range parts {
|
||||
parts[i] = strings.TrimSpace(parts[i])
|
||||
if parts[i] == "" {
|
||||
return nil, fmt.Errorf("modules list contains an empty value")
|
||||
}
|
||||
}
|
||||
return parts, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user