Добавил выбор из кандидатов, если LLM не уверена в раскладке

This commit is contained in:
2026-06-14 16:43:50 +03:00
parent 4af3ad2dde
commit 7f7f5f69d4
16 changed files with 831 additions and 88 deletions
+19 -15
View File
@@ -115,12 +115,13 @@ type Match struct {
// Result — итог распознавания.
type Result struct {
Plan Plan
PreParse PreParse
Decision Decision
Match *Match // подтверждённый матч в базе (nil — нет)
Attempts int // сколько вызовов LLM понадобилось (вкл. ретраи разбора)
Raw string // сырой ответ LLM последней попытки (для recognition.raw_llm)
Plan Plan
PreParse PreParse
Decision Decision
Match *Match // подтверждённый единичный матч (nil — нет)
Candidates []metadata.Candidate // кандидаты базы для ручного выбора в review
Attempts int // сколько вызовов LLM понадобилось (вкл. ретраи)
Raw string // сырой ответ LLM последней попытки
}
// LLM — нужная recognize часть провайдера.
@@ -234,8 +235,9 @@ func (r *Recognizer) Recognize(ctx context.Context, in Input) (Result, error) {
}
// Сверка с базой: подтверждаем id + каноническое имя; при матче имя/год
// в плане заменяем на каноничные.
match := r.matchMetadata(ctx, plan)
// в плане заменяем на каноничные. Кандидаты копим для ручного выбора в
// review, когда единичного сильного матча нет.
match, candidates := r.matchMetadata(ctx, plan)
if match != nil {
plan.Title = match.Title
if match.Year != 0 {
@@ -247,13 +249,15 @@ func (r *Recognizer) Recognize(ctx context.Context, in Input) (Result, error) {
r.log.Info("recognize: done",
"type", plan.Type, "title", plan.Title, "year", plan.Year,
"files", len(plan.Files), "attempts", attempts,
"matched", match != nil, "auto", dec.Auto, "reasons", len(dec.Reasons))
"matched", match != nil, "candidates", len(candidates),
"auto", dec.Auto, "reasons", len(dec.Reasons))
return Result{
Plan: plan,
PreParse: pre,
Decision: dec,
Match: match,
Attempts: attempts,
Raw: raw,
Plan: plan,
PreParse: pre,
Decision: dec,
Match: match,
Candidates: candidates,
Attempts: attempts,
Raw: raw,
}, nil
}