Add structured output repair configuration

This commit is contained in:
2026-08-25 19:47:42 +00:00
parent 0ef8931697
commit 9a92212632
6 changed files with 326 additions and 48 deletions

View File

@@ -116,6 +116,9 @@ func validatePipelineProfiles(profiles map[string]pipeline.PipelineProfile) erro
if profile.ID != "" && strings.TrimSpace(profile.ID) != id {
return fmt.Errorf("pipeline %q profile id %q does not match map key", id, profile.ID)
}
if err := validateStructuredOutputRepairAttempts(fmt.Sprintf("pipeline %q", id), profile.StructuredOutputRepairAttempts); err != nil {
return err
}
if err := validateBinding(id, "", "input", profile.Input, false); err != nil {
return err
}
@@ -195,6 +198,9 @@ func validateBinding(
binding pipeline.ModuleBinding,
referencesAllowed bool,
) error {
if err := validateStructuredOutputRepairAttempts(referenceContext(pipelineID, laneID, slot), binding.StructuredOutputRepairAttempts); err != nil {
return err
}
if err := validateBindingLLMProfile(pipelineID, laneID, slot, binding); err != nil {
return err
}
@@ -219,6 +225,13 @@ func validateBinding(
return validateReferenceMapForContext(pipelineID, laneID, slot, binding.References, true)
}
func validateStructuredOutputRepairAttempts(context string, attempts *int) error {
if attempts != nil && (*attempts < 0 || *attempts > 3) {
return fmt.Errorf("%s structured_output_repair_attempts must be between zero and three", context)
}
return nil
}
func validateValidatorOverride(pipelineID string, laneID string, slot string, override pipeline.ValidatorOverride) error {
if !override.Set {
return nil
@@ -230,6 +243,9 @@ func validateValidatorOverride(pipelineID string, laneID string, slot string, ov
}
for i, validator := range override.Validators {
context := fmt.Sprintf("%s validators[%d]", referenceContext(pipelineID, laneID, slot), i)
if err := validateStructuredOutputRepairAttempts(context, validator.StructuredOutputRepairAttempts); err != nil {
return err
}
if strings.TrimSpace(validator.Module) == "" {
return fmt.Errorf("%s module must not be empty", context)
}