Skip to content

The agent engineering platform.

community: add a flag that determines whether to load the milvus collection (#15693)

YHWce21392a2138
diff --git a/libs/community/langchain_community/vectorstores/milvus.py b/libs/community/langchain_community/vectorstores/milvus.py
index 4c626edce8..ed751271e0 100644
--- a/libs/community/langchain_community/vectorstores/milvus.py
+++ b/libs/community/langchain_community/vectorstores/milvus.py
@@ -446,9 +446,15 @@ class Milvus(VectorStore):
timeout: Optional[float] = None,
) -> None:
"""Load the collection if available."""
- from pymilvus import Collection
-
- if isinstance(self.col, Collection) and self._get_index() is not None:
+ from pymilvus import Collection, utility
+ from pymilvus.client.types import LoadState
+
+ if (
+ isinstance(self.col, Collection)
+ and self._get_index() is not None
+ and utility.load_state(self.collection_name, using=self.alias)
+ == LoadState.NotLoad
+ ):
self.col.load(
partition_names=partition_names,
replica_number=replica_number,