Configure correction repair profiles and budgets
This commit is contained in:
@@ -48,6 +48,7 @@ type ModuleRunSpec struct {
|
||||
CaptureProposalExchange bool `json:"-"`
|
||||
ProposalClient StructuredLLMClient `json:"-"`
|
||||
ValidationClient StructuredLLMClient `json:"-"`
|
||||
RepairClient StructuredLLMClient `json:"-"`
|
||||
}
|
||||
|
||||
// SectionMetadata captures chunk-level metadata without embedding full segment payloads.
|
||||
|
||||
@@ -116,10 +116,17 @@ func CheckReadiness(ctx context.Context, cfg *config.Config, inspectProfile func
|
||||
}
|
||||
}
|
||||
for index, item := range cfg.Pipeline.Stages {
|
||||
for _, selection := range []struct {
|
||||
selections := []struct {
|
||||
role string
|
||||
profile *string
|
||||
}{{"proposal", item.LLM.ProposalProfile}, {"validation", item.LLM.ValidationProfile}} {
|
||||
}{{"proposal", item.LLM.ProposalProfile}, {"validation", item.LLM.ValidationProfile}}
|
||||
if item.LLM.CorrectionRepairAttempts > 0 {
|
||||
selections = append(selections, struct {
|
||||
role string
|
||||
profile *string
|
||||
}{"correction repair", item.LLM.CorrectionRepairProfile})
|
||||
}
|
||||
for _, selection := range selections {
|
||||
if selection.profile == nil || *selection.profile == "" {
|
||||
return fmt.Errorf("%s requires a %s profile", label(index, item), selection.role)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package preflight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -37,3 +38,26 @@ func TestEmptyPipelineNeedsNoProfile(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCorrectionRepairReadinessDependsOnBudget(t *testing.T) {
|
||||
proposal, repair := "proposal", "missing"
|
||||
cfg := &config.Config{Pipeline: config.Pipeline{Stages: []config.Stage{{Module: "grammar", LLM: config.LLM{ProposalProfile: &proposal, ValidationProfile: &proposal, CorrectionRepairProfile: &repair}}}}}
|
||||
inspect := func(_ context.Context, id string) error {
|
||||
if id == repair {
|
||||
return fmt.Errorf("unknown profile")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := CheckReadiness(context.Background(), cfg, inspect); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg.Pipeline.Stages[0].LLM.CorrectionRepairAttempts = 1
|
||||
output := filepath.Join(t.TempDir(), "transcript.json")
|
||||
_, err := Prepare(context.Background(), Input{Config: cfg, Transcript: &schema.SourceTranscript{}, Output: diagnostics.OutputSelection{TranscriptPath: output}, InspectProfile: inspect})
|
||||
if err == nil || !strings.Contains(err.Error(), "correction repair") {
|
||||
t.Fatalf("readiness error: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(output); !os.IsNotExist(err) {
|
||||
t.Fatalf("output exists: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user