Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: incorrect score in the chroma vector (#14273)

Rhys548f6ef2b6bd
diff --git a/api/core/rag/datasource/vdb/chroma/chroma_vector.py b/api/core/rag/datasource/vdb/chroma/chroma_vector.py
index 907c4d22854..81a1207d1df 100644
--- a/api/core/rag/datasource/vdb/chroma/chroma_vector.py
+++ b/api/core/rag/datasource/vdb/chroma/chroma_vector.py
@@ -111,8 +111,9 @@ class ChromaVector(BaseVector):
for index in range(len(ids)):
distance = distances[index]
metadata = dict(metadatas[index])
- if distance >= score_threshold:
- metadata["score"] = distance
+ score = 1 - distance
+ if score > score_threshold:
+ metadata["score"] = score
doc = Document(
page_content=documents[index],
metadata=metadata,