Skip to content

Commit 39e8792

Browse files
fix: add l2 distance metric support for backward compatibility (#3540)
1 parent 2f682e1 commit 39e8792

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/crewai/rag/chromadb/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ def _convert_distance_to_score(
133133
if distance_metric == "cosine":
134134
score = 1.0 - 0.5 * distance
135135
return max(0.0, min(1.0, score))
136+
if distance_metric == "l2":
137+
score = 1.0 / (1.0 + distance)
138+
return max(0.0, min(1.0, score))
136139
raise ValueError(f"Unsupported distance metric: {distance_metric}")
137140

138141

0 commit comments

Comments
 (0)