From 2000d47406ba4efea83a39c1a77634bbb3487056 Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Tue, 4 Jun 2024 02:12:03 +0800 Subject: [PATCH] Fix chromadb get_collection ignores custom embedding_function (#2854) --- autogen/agentchat/contrib/vectordb/chromadb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autogen/agentchat/contrib/vectordb/chromadb.py b/autogen/agentchat/contrib/vectordb/chromadb.py index 3f1fbc86a..1ed870840 100644 --- a/autogen/agentchat/contrib/vectordb/chromadb.py +++ b/autogen/agentchat/contrib/vectordb/chromadb.py @@ -83,7 +83,7 @@ class ChromaVectorDB(VectorDB): if self.active_collection and self.active_collection.name == collection_name: collection = self.active_collection else: - collection = self.client.get_collection(collection_name) + collection = self.client.get_collection(collection_name, embedding_function=self.embedding_function) except ValueError: collection = None if collection is None: @@ -126,7 +126,9 @@ class ChromaVectorDB(VectorDB): ) else: if not (self.active_collection and self.active_collection.name == collection_name): - self.active_collection = self.client.get_collection(collection_name) + self.active_collection = self.client.get_collection( + collection_name, embedding_function=self.embedding_function + ) return self.active_collection def delete_collection(self, collection_name: str) -> None: