Registry / llm-agents / langchain-milvus

langchain-milvus

JSON →
library0.4.0pypypi✓ verified 21d ago

langchain-milvus is an integration package that connects Milvus, a powerful open-source vector database, with LangChain, a framework for building applications with large language models (LLMs). It enables efficient vector storage and retrieval for AI applications like semantic search and RAG. The library is actively maintained with frequent updates, typically releasing minor versions with new features and potentially breaking changes, and patch versions for bug fixes and improvements.

pip install -qU langchain-milvus milvus-lite langchain-openai
INSTALL
IMPORT
SIG · LANGCHAIN-MILVUS
L
langchain-milvus
llm-agentspythonv0.4.0
Install
20.4s avg
Import
4371ms
Disk
508MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 22.5s
py 3.11
✓ —
✓ 19.9s
py 3.12
✓ —
✓ 18s
py 3.13
✓ —
✓ 18.5s
py 3.9
✕ build_error
✓ 22.9s
508MB installed
● package 508MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Milvus
from langchain_milvus import Milvus
from langchain.vectorstores import Milvus
The `Milvus` class was moved from the `langchain.vectorstores` module to `langchain_milvus` in `langchain` 0.2.0.
MilvusCollectionHybridSearchRetriever
from langchain_milvus import MilvusCollectionHybridSearchRetriever
Used for hybrid search capabilities within LangChain.

This quickstart demonstrates how to initialize the Milvus vector store, add documents with an embedding function (OpenAI Embeddings), and perform a similarity search. It uses Milvus Lite for local file-based storage.

import os from langchain_milvus import Milvus from langchain_openai import OpenAIEmbeddings from langchain_core.documents import Document # Ensure OPENAI_API_KEY is set in your environment # Replace 'YOUR_OPENAI_API_KEY' with your actual key if not using env vars. os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "sk-...") # Initialize embeddings embeddings = OpenAIEmbeddings() # Connect to Milvus Lite (local file) or a Milvus server. # For Milvus Lite, use a local file path as the URI. E.g., "./milvus_example.db" # For a Milvus server, use its URI, e.g., "http://localhost:19530" MILVUS_URI = "./milvus_example.db" # Create a Milvus vector store vector_store = Milvus( embedding_function=embeddings, collection_name="my_langchain_documents", connection_args={"uri": MILVUS_URI}, auto_id=True # Milvus 2.2.0 or later supports auto-generated IDs ) # Add documents documents = [ Document(page_content="The quick brown fox jumps over the lazy dog.", metadata={"source": "lorem"}), Document(page_content="Milvus is an open-source vector database designed for AI applications.", metadata={"source": "milvus_docs"}), Document(page_content="LangChain is a framework for developing applications with LLMs.", metadata={"source": "langchain_docs"}), ] vector_store.add_documents(documents) # Perform a similarity search query = "What is LangChain used for?" results = vector_store.similarity_search(query, k=1) print("Similarity search results:") for doc in results: print(f"- Content: {doc.page_content[:60]}... Metadata: {doc.metadata}")
Debug
Known issues
breakingVersion 0.3.0 introduced a significant refactor, replacing the Milvus ORM (Object-Relational Mapping) with the lower-level Milvus Client API. If your code directly interacted with internal ORM specifics, it might require updates.
fix
Review the Milvus client API documentation and adjust custom interactions that previously relied on the ORM layer.
affects: >=0.3.0
breakingVersion 0.2.2 updated internal dependencies to support `langchain-core` 1.0.0. Ensure your `langchain-core` installation is compatible (preferably 1.0.0 or newer) to avoid potential dependency conflicts or unexpected behavior.
fix
Upgrade `langchain-core` to `^1.0.0` or ensure it's a compatible version with your `langchain-milvus` installation.
affects: >=0.2.2
deprecatedThe `Milvus` class was deprecated in `langchain` version 0.2.0 and moved to its dedicated integration package, `langchain-milvus`. Using the old import path (`from langchain.vectorstores import Milvus`) will raise warnings or errors in newer LangChain versions.
fix
Update your imports to `from langchain_milvus import Milvus`.
affects: langchain>=0.2.0
gotchaConnecting to Milvus: Milvus Lite (local file-based) is suitable for development and small datasets, requiring a URI like `./milvus_example.db`. For production or large-scale data, a full Milvus server (Docker/Kubernetes) is recommended, requiring a server URI (e.g., `http://localhost:19530`). Features like `partition_key` for multi-tenancy are often only available with a Milvus server.
fix
Choose the appropriate Milvus setup based on your needs and configure the `connection_args={'uri': ...}` accordingly.
affects: all
gotchaThe reranker functionality was refactored in version 0.3.3 to adapt to Milvus 2.6. If you have custom reranker implementations, they might need adjustments to align with the new function signature or expected behavior.
fix
Review the changelog for `v0.3.3` and LangChain documentation regarding reranker usage with Milvus 2.6 to update any custom reranker logic.
affects: >=0.3.3
gotchaWith LangChain 1.0 and above, `langchain-core` is often treated as a peer dependency. This means you need to explicitly manage the versions of `langchain`, `langchain-core`, and `langchain-milvus` to ensure compatibility and avoid dependency conflicts, especially when upgrading.
fix
Always use a virtual environment and pin package versions or rely on tools like Poetry or `pip-tools` for consistent dependency resolution across your LangChain ecosystem packages.
affects: langchain>=1.0.0, langchain-milvus>=0.2.2
Upgrade
Version history
0.4.0latest on PyPI · released Jul 17, 2026
Audit
Dependencies
pymilvusrequiredRequired for interacting with the Milvus vector database.
langchain-corerequiredPeer dependency in the LangChain 1.0+ ecosystem; critical for core LangChain functionalities.
langchain-openaioptionalCommonly used for OpenAI embedding models in quickstart examples.
Agent activity
69 hits · last 30 days
node
62
OpenAI (training)
2
Amazon
1
Resources
langchain-milvus — pip install langchain-milvus · libregistry