From 741230bcdbf8ea6cc8d673e61cc712efd96e6bb8 Mon Sep 17 00:00:00 2001 From: Jannik Streidl Date: Thu, 10 Oct 2024 17:20:50 +0200 Subject: [PATCH] fix --- backend/open_webui/apps/retrieval/vector/dbs/chroma.py | 5 ++++- src/lib/components/chat/Messages/Citations.svelte | 9 --------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/backend/open_webui/apps/retrieval/vector/dbs/chroma.py b/backend/open_webui/apps/retrieval/vector/dbs/chroma.py index da5382c32..c6d95bd52 100644 --- a/backend/open_webui/apps/retrieval/vector/dbs/chroma.py +++ b/backend/open_webui/apps/retrieval/vector/dbs/chroma.py @@ -130,7 +130,10 @@ class ChromaClient: def upsert(self, collection_name: str, items: list[VectorItem]): # Update the items in the collection, if the items are not present, insert them. If the collection does not exist, it will be created. - collection = self.client.get_or_create_collection(name=collection_name) + collection = self.client.get_or_create_collection( + name=collection_name, + metadata={"hnsw:space": "cosine"} + ) ids = [item["id"] for item in items] documents = [item["text"] for item in items] diff --git a/src/lib/components/chat/Messages/Citations.svelte b/src/lib/components/chat/Messages/Citations.svelte index 162ad6683..9ab3b31ae 100644 --- a/src/lib/components/chat/Messages/Citations.svelte +++ b/src/lib/components/chat/Messages/Citations.svelte @@ -49,15 +49,6 @@ }); return acc; }, []); - - $: if (_citations.every((citation) => citation.distances !== undefined)) { - // Sort citations by distance (relevance) - _citations = _citations.sort((a, b) => { - const aMinDistance = Math.min(...(a.distances ?? [])); - const bMinDistance = Math.min(...(b.distances ?? [])); - return aMinDistance - bMinDistance; - }); - }