Unify structured call completion and retain typed failures
This commit is contained in:
@@ -5,7 +5,6 @@ package proposal_generation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -129,15 +128,9 @@ func GenerateCandidates(ctx context.Context, req Request) (Result, error) {
|
||||
}
|
||||
|
||||
if callErr != nil {
|
||||
var failure *structuredoutput.Failure
|
||||
if errors.As(callErr, &failure) {
|
||||
operation.FailureReason = failure.Reason
|
||||
}
|
||||
if operation.FailureReason == "" {
|
||||
operation.FailureReason = outcomes.ReasonInternalFailure
|
||||
}
|
||||
structuredoutput.RecordFailure(&operation, callErr)
|
||||
result := Result{Operations: []outcomes.Operation{operation}, Artifacts: artifacts}
|
||||
if structuredoutput.IsRecoverable(callErr) && failure != nil && failure.Reason != "" {
|
||||
if operation.FailureClass == outcomes.FailureRecoverable {
|
||||
return result, nil
|
||||
}
|
||||
return result, fmt.Errorf("proposal generation completion failed: %w", callErr)
|
||||
|
||||
Reference in New Issue
Block a user