From 25c4c24e896beabc6c62ddc7263160f3e8b6dd49 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 18 Apr 2024 18:28:00 +0530 Subject: [PATCH] Support to create shards_num in milvus vectorstores (#20318) To support number of the shards for the collection to create in milvus vvectorstores. Thank you for contributing to LangChain! - [ ] **PR title**: "package: description" - Where "package" is whichever of langchain, community, core, experimental, etc. is being modified. Use "docs: ..." for purely docs changes, "templates: ..." for template changes, "infra: ..." for CI changes. - Example: "community: add foobar LLM" - [ ] **PR message**: ***Delete this entire checklist*** and replace with - **Description:** a description of the change - **Issue:** the issue # it fixes, if applicable - **Dependencies:** any dependencies required for this change - **Twitter handle:** if your PR gets announced, and you'd like a mention, we'll gladly shout you out! - [ ] **Add tests and docs**: If you're adding a new integration, please include 1. a test for the integration, preferably unit tests that do not rely on network access, 2. an example notebook showing its use. It lives in `docs/docs/integrations` directory. - [ ] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/ Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, hwchase17. --- libs/community/langchain_community/vectorstores/milvus.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/community/langchain_community/vectorstores/milvus.py b/libs/community/langchain_community/vectorstores/milvus.py index f1d3e0d929..1e14ad246c 100644 --- a/libs/community/langchain_community/vectorstores/milvus.py +++ b/libs/community/langchain_community/vectorstores/milvus.py @@ -133,6 +133,7 @@ class Milvus(VectorStore): partition_names: Optional[list] = None, replica_number: int = 1, timeout: Optional[float] = None, + num_shards: Optional[int] = None, ): """Initialize the Milvus vector store.""" try: @@ -191,6 +192,7 @@ class Milvus(VectorStore): self.partition_names = partition_names self.replica_number = replica_number self.timeout = timeout + self.num_shards = num_shards # Create the connection to the server if connection_args is None: @@ -381,6 +383,7 @@ class Milvus(VectorStore): schema=schema, consistency_level=self.consistency_level, using=self.alias, + num_shards=self.num_shards, ) # Set the collection properties if they exist if self.collection_properties is not None: