Map PromptKit repair results and generation errors
This commit is contained in:
@@ -153,6 +153,7 @@ func outputContract(value promptkit.OutputContract) promptexec.OutputContract {
|
||||
Format: string(value.Format),
|
||||
ValidationMode: string(value.ValidationMode),
|
||||
SchemaPath: value.SchemaPath,
|
||||
RepairAttempts: value.RepairAttempts,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +194,7 @@ func executionValue(value *promptkit.RunResult, captureDebug bool) *promptexec.E
|
||||
promptexec.ValidationStatus(value.Validation.Status),
|
||||
string(value.Validation.Mode),
|
||||
value.Validation.SchemaPath,
|
||||
0,
|
||||
value.Validation.RepairAttempts,
|
||||
value.Validation.Errors,
|
||||
)
|
||||
rawOutput := []byte(nil)
|
||||
@@ -204,7 +205,7 @@ func executionValue(value *promptkit.RunResult, captureDebug bool) *promptexec.E
|
||||
promptexec.ValidationFailed,
|
||||
string(value.Validation.Mode),
|
||||
value.Validation.SchemaPath,
|
||||
0,
|
||||
value.Validation.RepairAttempts,
|
||||
[]string{"generated output exceeds the configured size limit"},
|
||||
)
|
||||
}
|
||||
@@ -301,6 +302,16 @@ func classifyError(err error) error {
|
||||
if errors.As(err, &capacityError) {
|
||||
return promptexec.NewCapacityError(capacityError.BackendID, "prompt backend capacity is unavailable", err)
|
||||
}
|
||||
var generationError *promptkit.GenerationError
|
||||
if errors.As(err, &generationError) {
|
||||
return promptexec.NewGenerationError(
|
||||
generationError.StatusCode(),
|
||||
generationError.ProviderCode(),
|
||||
generationError.ProviderType(),
|
||||
generationError.ProviderMessage(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
switch {
|
||||
case errors.Is(err, promptkit.ErrInvalidConfig):
|
||||
return promptexec.NewError(promptexec.InvalidConfiguration, "prompt executor configuration is invalid", err)
|
||||
|
||||
Reference in New Issue
Block a user