Use prompt-defined structured output contracts
This commit is contained in:
@@ -50,7 +50,6 @@ type LLM struct {
|
||||
CorrectionRepairProfile *string `yaml:"correction_repair_profile"`
|
||||
CorrectionRepairAttempts int `yaml:"correction_repair_attempts"`
|
||||
TransientRetries int `yaml:"transient_retries"`
|
||||
RepairAttempts int `yaml:"repair_attempts"`
|
||||
OperationTimeout time.Duration `yaml:"operation_timeout"`
|
||||
}
|
||||
type Pipeline struct {
|
||||
@@ -96,7 +95,7 @@ type Reporting struct {
|
||||
func defaults() Config {
|
||||
return Config{
|
||||
Version: 3,
|
||||
LLM: LLM{TransientRetries: 2, RepairAttempts: 2, CorrectionRepairAttempts: 1, OperationTimeout: 15 * time.Minute},
|
||||
LLM: LLM{TransientRetries: 2, CorrectionRepairAttempts: 1, OperationTimeout: 15 * time.Minute},
|
||||
Pipeline: Pipeline{Stages: []Stage{{Module: "glossary"}, {Module: "homophones"}, {Module: "glossary"}, {Module: "spoken_word"}, {Module: "grammar"}}},
|
||||
Output: Output{Schema: "bare-segments"},
|
||||
Validation: Validation{MaxPromptTokens: DefaultValidationMaxPromptTokens},
|
||||
@@ -176,7 +175,6 @@ func validate(c *Config, v *ck.Validation) {
|
||||
func validateRuntimeSettings(check func(bool, ck.Path, string), base ck.Path, settings LLM, validation Validation, context Context) {
|
||||
llm := base.Key("llm")
|
||||
check(settings.TransientRetries >= 0, llm.Key("transient_retries"), "retry budget must be non-negative")
|
||||
check(settings.RepairAttempts >= 0 && settings.RepairAttempts <= 3, llm.Key("repair_attempts"), "repair attempts must be between zero and three")
|
||||
check(settings.CorrectionRepairAttempts >= 0, llm.Key("correction_repair_attempts"), "correction repair attempts must be non-negative")
|
||||
check(settings.CorrectionRepairProfile == nil || *settings.CorrectionRepairProfile != "", llm.Key("correction_repair_profile"), "correction repair profile must not be empty; use null to clear it")
|
||||
check(settings.OperationTimeout > 0, llm.Key("operation_timeout"), "operation timeout must be positive")
|
||||
|
||||
@@ -51,7 +51,8 @@ func TestSchemaConstraintsAndExplicitValues(t *testing.T) {
|
||||
{"unknown module", "pipeline:\n stages:\n - module: unknown\n", false},
|
||||
{"invalid chunk limit", "chunking:\n target_sections: 0\n", false},
|
||||
{"null group", "llm: null\n", false},
|
||||
{"zero budgets", "llm:\n transient_retries: 0\n repair_attempts: 0\n", true},
|
||||
{"zero retries", "llm:\n transient_retries: 0\n", true},
|
||||
{"retired repair budget", "llm:\n repair_attempts: 0\n", false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if err := os.WriteFile(path, []byte(tc.text), 0644); err != nil {
|
||||
|
||||
@@ -63,7 +63,6 @@ func resolveSettings(c *Config, r *ck.Resolution) error {
|
||||
proposal := llm.Key("proposal_profile")
|
||||
ck.Default(r, proposal, &item.LLM.ProposalProfile, cloneSelection(c.LLM.ProposalProfile), "inherit proposal profile", rootLLM.Key("proposal_profile"))
|
||||
ck.Default(r, llm.Key("transient_retries"), &item.LLM.TransientRetries, c.LLM.TransientRetries, "inherit retry budget", rootLLM.Key("transient_retries"))
|
||||
ck.Default(r, llm.Key("repair_attempts"), &item.LLM.RepairAttempts, c.LLM.RepairAttempts, "inherit repair budget", rootLLM.Key("repair_attempts"))
|
||||
ck.Default(r, llm.Key("correction_repair_attempts"), &item.LLM.CorrectionRepairAttempts, c.LLM.CorrectionRepairAttempts, "inherit correction repair budget", rootLLM.Key("correction_repair_attempts"))
|
||||
ck.Default(r, llm.Key("operation_timeout"), &item.LLM.OperationTimeout, c.LLM.OperationTimeout, "inherit operation timeout", rootLLM.Key("operation_timeout"))
|
||||
ck.Default(r, base.Key("validation").Key("max_prompt_tokens"), &item.Validation.MaxPromptTokens, c.Validation.MaxPromptTokens, "inherit validation budget", ck.Keys("validation", "max_prompt_tokens"))
|
||||
|
||||
@@ -27,7 +27,6 @@ func TestResolutionCopiesRootOverridesAndHonorsClears(t *testing.T) {
|
||||
glossaries: [party]
|
||||
llm:
|
||||
proposal_profile: A
|
||||
repair_attempts: 2
|
||||
context:
|
||||
description: root
|
||||
pipeline:
|
||||
@@ -36,7 +35,6 @@ pipeline:
|
||||
glossaries: [party]
|
||||
llm:
|
||||
proposal_profile: B
|
||||
repair_attempts: 0
|
||||
context:
|
||||
description: ""
|
||||
- module: grammar
|
||||
@@ -52,7 +50,7 @@ pipeline:
|
||||
if !reflect.DeepEqual(cfg.ProtectedTerms, []string{"spells"}) || !reflect.DeepEqual(cfg.Pipeline.Stages[0].Glossaries, []string{"party"}) || !reflect.DeepEqual(cfg.Pipeline.Stages[1].Glossaries, []string{"spells"}) || len(cfg.Pipeline.Stages[2].Glossaries) != 0 {
|
||||
t.Fatalf("resolved: %+v", cfg)
|
||||
}
|
||||
if cfg.Pipeline.Stages[1].ProtectedTerms != nil || cfg.Pipeline.Stages[0].LLM.RepairAttempts != 0 || cfg.Pipeline.Stages[0].Context.Description != "" {
|
||||
if cfg.Pipeline.Stages[1].ProtectedTerms != nil || cfg.Pipeline.Stages[0].Context.Description != "" {
|
||||
t.Fatalf("clears lost: %+v", cfg.Pipeline.Stages)
|
||||
}
|
||||
if *cfg.Pipeline.Stages[0].LLM.ValidationProfile != "B" || *cfg.Pipeline.Stages[1].LLM.ValidationProfile != "A" {
|
||||
|
||||
Reference in New Issue
Block a user