fix(rerank): filter empty passages to prevent Aliyun API error

Aliyun rerank API rejects empty documents with error "document index:X
should not be empty". This fix validates passage content before building
the documents array, skipping empty chunks and logging them for data
quality monitoring.
This commit is contained in:
ChenRussell
2026-03-25 14:47:44 +08:00
committed by lyingbug
parent 804a17d58c
commit bfa78cc933
@@ -82,6 +82,13 @@ func (p *PluginRerank) OnEvent(ctx context.Context,
}
// 合并Content和ImageInfo的文本内容
passage := getEnrichedPassage(ctx, result)
// 过滤空内容,避免Rerank API报错
if strings.TrimSpace(passage) == "" {
pipelineWarn(ctx, "Rerank", "empty_passage_skip", map[string]interface{}{
"chunk_id": result.ID,
})
continue
}
passages = append(passages, passage)
candidatesToRerank = append(candidatesToRerank, result)
}