fix(layers): clamp similarity to [0,1] to avoid negative values

This commit is contained in:
bobo-xxx
2026-04-18 12:41:12 +08:00
committed by Igor Lins e Silva
parent eef053d750
commit f2bed9284f
+1 -1
View File
@@ -287,7 +287,7 @@ class Layer3:
for i, (doc, meta, dist) in enumerate(zip(docs, metas, dists), 1):
meta = meta or {}
doc = doc or ""
similarity = round(1 - dist, 3)
similarity = round(max(0.0, 1 - dist), 3)
wing_name = meta.get("wing", "?")
room_name = meta.get("room", "?")
source = Path(meta.get("source_file", "")).name if meta.get("source_file") else ""