Skip to content

A programming framework for agentic AI

Fix chromadb get_collection ignores custom embedding_function (#2854)

Li Jiang2000d47406ba
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: