Carry one proposal result from generation to the runner
This commit is contained in:
@@ -42,7 +42,6 @@ type Request struct {
|
||||
PromptID string `json:"prompt_id"`
|
||||
Variables map[string]string `json:"variables"`
|
||||
StageName string `json:"stage_name,omitempty"`
|
||||
StartIndex int `json:"start_index"`
|
||||
CaptureExchange bool
|
||||
LLMClient contracts.StructuredLLMClient
|
||||
Interactions structuredoutput.InteractionSink
|
||||
@@ -50,12 +49,8 @@ type Request struct {
|
||||
|
||||
// Result contains generated candidate proposals and optional diagnostics paths.
|
||||
type Result struct {
|
||||
SegmentReferences []int `json:"-"`
|
||||
Exchange *structuredoutput.Exchange `json:"-"`
|
||||
Corrections []proposals.CorrectionProposal `json:"corrections"`
|
||||
Enriched []proposals.EnrichedCorrectionProposal `json:"enriched"`
|
||||
Operations []outcomes.Operation `json:"operations,omitempty"`
|
||||
Artifacts structuredoutput.InteractionArtifacts `json:"artifacts,omitempty"`
|
||||
contracts.ProposalResult
|
||||
Artifacts structuredoutput.InteractionArtifacts `json:"artifacts,omitempty"`
|
||||
}
|
||||
|
||||
// GenerateCandidates executes one structured LLM call and deterministically maps
|
||||
@@ -67,9 +62,6 @@ func GenerateCandidates(ctx context.Context, req Request) (Result, error) {
|
||||
if strings.TrimSpace(req.ModuleInstance) == "" {
|
||||
return Result{}, fmt.Errorf("module instance must not be empty")
|
||||
}
|
||||
if req.StartIndex < 0 {
|
||||
return Result{}, fmt.Errorf("start index must be non-negative")
|
||||
}
|
||||
if req.LLMClient == nil {
|
||||
return Result{}, fmt.Errorf("structured LLM client is required")
|
||||
}
|
||||
@@ -115,7 +107,7 @@ func GenerateCandidates(ctx context.Context, req Request) (Result, error) {
|
||||
"module_instance": req.ModuleInstance,
|
||||
"replacement_policy": req.ReplacementPolicy,
|
||||
"section": req.Section,
|
||||
"start_index": req.StartIndex,
|
||||
"start_index": 0, // Position of the first item within this response.
|
||||
"segment_ids": segmentIDs(req.WorkingTranscript),
|
||||
"prompt": completion.Prompt,
|
||||
}
|
||||
@@ -129,7 +121,7 @@ func GenerateCandidates(ctx context.Context, req Request) (Result, error) {
|
||||
|
||||
if callErr != nil {
|
||||
structuredoutput.RecordFailure(&operation, callErr)
|
||||
result := Result{Operations: []outcomes.Operation{operation}, Artifacts: artifacts}
|
||||
result := Result{ProposalResult: contracts.ProposalResult{Operations: []outcomes.Operation{operation}}, Artifacts: artifacts}
|
||||
if operation.FailureClass == outcomes.FailureRecoverable {
|
||||
return result, nil
|
||||
}
|
||||
@@ -140,39 +132,23 @@ func GenerateCandidates(ctx context.Context, req Request) (Result, error) {
|
||||
|
||||
references := make([]int, 0, len(response.Corrections))
|
||||
corrections := make([]proposals.CorrectionProposal, 0, len(response.Corrections))
|
||||
enriched := make([]proposals.EnrichedCorrectionProposal, 0, len(response.Corrections))
|
||||
for i, raw := range response.Corrections {
|
||||
for _, raw := range response.Corrections {
|
||||
references = append(references, raw.SegmentReference)
|
||||
// Unknown references remain invalid candidates for the existing domain validators.
|
||||
candidate := proposals.CorrectionProposal{
|
||||
corrections = append(corrections, proposals.CorrectionProposal{
|
||||
TargetSegmentID: proposals.SegmentIDAtReference(req.WorkingTranscript, raw.SegmentReference),
|
||||
OriginalText: raw.OriginalText,
|
||||
CorrectedText: raw.CorrectedText,
|
||||
}
|
||||
|
||||
corrections = append(corrections, candidate)
|
||||
enrichedCandidate := proposals.EnrichedCorrectionProposal{
|
||||
CorrectionProposal: candidate,
|
||||
ProposalMetadata: proposals.ProposalMetadata{
|
||||
ProposalIndex: req.StartIndex + i,
|
||||
ModuleKey: req.ModuleKey,
|
||||
ModuleInstance: req.ModuleInstance,
|
||||
},
|
||||
}
|
||||
if req.Section != nil {
|
||||
sectionIndex := req.Section.Index
|
||||
enrichedCandidate.SectionIndex = §ionIndex
|
||||
}
|
||||
enriched = append(enriched, enrichedCandidate)
|
||||
})
|
||||
}
|
||||
|
||||
return Result{
|
||||
Corrections: corrections,
|
||||
SegmentReferences: references,
|
||||
Exchange: completion.Exchange,
|
||||
Enriched: enriched,
|
||||
Operations: []outcomes.Operation{operation},
|
||||
Artifacts: artifacts,
|
||||
ProposalResult: contracts.ProposalResult{
|
||||
Proposals: corrections,
|
||||
SegmentReferences: references,
|
||||
Exchange: completion.Exchange,
|
||||
Operations: []outcomes.Operation{operation},
|
||||
},
|
||||
Artifacts: artifacts,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user