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

fix https://github.com/langchain-ai/langchain/issues/15694

---------

Co-authored-by: hyungwookyang <hyungwookyang@worksmobile.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
YHW 2024-01-16 04:25:23 +09:00 committed by GitHub
parent 9e779ca846
commit ce21392a21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -446,9 +446,15 @@ class Milvus(VectorStore):
timeout: Optional[float] = None, timeout: Optional[float] = None,
) -> None: ) -> None:
"""Load the collection if available.""" """Load the collection if available."""
from pymilvus import Collection from pymilvus import Collection, utility
from pymilvus.client.types import LoadState
if isinstance(self.col, Collection) and self._get_index() is not None: 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( self.col.load(
partition_names=partition_names, partition_names=partition_names,
replica_number=replica_number, replica_number=replica_number,