milvus: add_db_milvus_connection (#25627)

Thank you for contributing to LangChain!

- [x] **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"
  - "libs: langchain_milvus: add db name to milvus connection check"


- [x] **PR message**: ***Delete this entire checklist*** and replace
with
    - **Description:**  add db name to milvus connection check
    - **Issue:** https://github.com/langchain-ai/langchain/issues/25277



- [x] **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.


- [x] **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, ccurme, vbarda, hwchase17.

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
venkatram-dev 2024-08-26 10:29:12 -07:00 committed by GitHub
parent af3b3a4474
commit ec99f0d193
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -351,6 +351,7 @@ class Milvus(VectorStore):
address: str = connection_args.get("address", None)
uri: str = connection_args.get("uri", None)
user = connection_args.get("user", None)
db_name = connection_args.get("db_name", "default")
# Order of use is host/port, uri, address
if host is not None and port is not None:
@ -384,6 +385,7 @@ class Milvus(VectorStore):
and (addr["address"] == given_address)
and ("user" in addr)
and (addr["user"] == tmp_user)
and (addr["db_name"] == db_name)
):
logger.debug("Using previous connection: %s", con[0])
return con[0]