Accept equivalent integer references in model responses

This commit is contained in:
2026-11-17 04:22:20 +00:00
parent 2d93e8ae7c
commit 44c767f285
10 changed files with 52 additions and 27 deletions

View File

@@ -8,6 +8,7 @@ import (
"fmt"
"strings"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/jsonnumber"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/contracts"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/outcomes"
@@ -19,9 +20,9 @@ import (
// StructuredCorrectionProposal is one LLM response correction payload.
type StructuredCorrectionProposal struct {
SegmentReference int `json:"id"`
OriginalText string `json:"original_text"`
CorrectedText string `json:"corrected_text"`
SegmentReference jsonnumber.Integer `json:"id"`
OriginalText string `json:"original_text"`
CorrectedText string `json:"corrected_text"`
}
// StructuredCorrectionSet is the reusable structured LLM response model for
@@ -134,10 +135,11 @@ func GenerateCandidates(ctx context.Context, req Request) (Result, error) {
references := make([]int, 0, len(response.Corrections))
corrections := make([]proposals.CorrectionProposal, 0, len(response.Corrections))
for _, raw := range response.Corrections {
references = append(references, raw.SegmentReference)
ref := int(raw.SegmentReference)
references = append(references, ref)
// Unknown references remain invalid candidates for the existing domain validators.
corrections = append(corrections, proposals.CorrectionProposal{
TargetSegmentID: proposals.SegmentIDAtReference(req.WorkingTranscript, raw.SegmentReference),
TargetSegmentID: proposals.SegmentIDAtReference(req.WorkingTranscript, ref),
OriginalText: raw.OriginalText,
CorrectedText: raw.CorrectedText,
})