fix: show relevance badge for single-source citations (#29647)

A response with exactly one citation never showed its relevance badge, even though the source carried a perfectly valid score. Adding a second citation made the badge appear for that same source, so the score looked like it came and went at random.

calculateShowRelevance hides relevance when a result set mixes distance metrics (cosine in -1..1 next to unbounded L2), since those numbers are not comparable. With a single distance that check degenerates: distances.length - 1 is 0, so the "all but one are out of range" clause matches whatever the value is, and the score is hidden. A lone distance cannot be a mix of two metrics, so it now returns before the outlier check runs.

Sets of two or more distances behave exactly as before, mixed-metric sets are still suppressed.

Fixes #29646
This commit is contained in:
Classic298 2026-09-04 23:17:14 +02:00 committed by GitHub
parent d75a7aaf54
commit 323f8da202
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -80,6 +80,11 @@
return false;
}
// A single distance cannot be an outlier
if (distances.length === 1) {
return true;
}
if (
(inRange === distances.length - 1 && outOfRange === 1) ||
(outOfRange === distances.length - 1 && inRange === 1)