feat: add Milvus vector index provider#457
Open
zc277584121 wants to merge 1 commit into
Open
Conversation
12 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an optional external vector-index abstraction to memU and ships a Milvus-backed implementation, wired into the inmemory metadata backend so similarity search can be offloaded to Milvus / Milvus Lite / Zilliz Cloud while keeping metadata in-memory.
Changes:
- Introduces a
VectorIndexprotocol plusMilvusVectorIndex(pymilvusMilvusClient) and a small factory to construct it fromDatabaseConfig. - Wires the external index into the
inmemoryitem repository for upsert/delete/clear mirroring and for non-salience similarity search routing. - Adds a
milvusoptional dependency group, docs/ADR, an end-to-end example, and Milvus Lite-backed tests.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Locks new optional Milvus-related dependencies (pymilvus, milvus-lite, grpcio, etc.). |
| tests/test_milvus_vector_index.py | Adds Milvus Lite round-trip tests plus filter-expression and dimension mismatch coverage. |
| src/memu/database/vector_index/milvus.py | Implements MilvusVectorIndex, including safe filter-expression building and collection bootstrap. |
| src/memu/database/vector_index/interfaces.py | Defines the new VectorIndex protocol contract. |
| src/memu/database/vector_index/init.py | Adds build_vector_index to construct providers from VectorIndexConfig. |
| src/memu/database/inmemory/repositories/memory_item_repo.py | Mirrors item mutations to the external index and routes similarity search through it (except salience). |
| src/memu/database/inmemory/repo.py | Plumbs vector_index into the inmemory store and closes it on shutdown. |
| src/memu/database/inmemory/init.py | Extends the inmemory database builder to accept and pass through a vector_index. |
| src/memu/database/factory.py | Constructs Milvus index for inmemory and rejects milvus config for non-inmemory stores. |
| src/memu/app/settings.py | Extends VectorIndexConfig to include milvus options (uri/token/collection/dim) and defaulting. |
| README.md | Documents how to run the Milvus Lite example via uv sync --extra milvus. |
| pyproject.toml | Adds [project.optional-dependencies].milvus and mypy override for pymilvus.*. |
| examples/milvus_vector_index.py | Adds a runnable MemoryService + Milvus Lite end-to-end example. |
| docs/milvus.md | Adds a user guide for configuring Milvus Lite/server/Zilliz Cloud. |
| docs/architecture.md | Updates architecture docs to describe database_config.vector_index provider options. |
| docs/adr/README.md | Adds the new ADR entry to the ADR index. |
| docs/adr/0006-external-vector-index.md | Adds ADR documenting the external vector index design and rollout constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return { | ||
| key: value | ||
| for key, value in item.model_dump().items() | ||
| if key not in _CORE_ITEM_FIELDS and isinstance(value, str | int | float | bool) |
Comment on lines
+48
to
+52
| ```python | ||
| database_config = { | ||
| "metadata_store": {"provider": "inmemory"}, | ||
| "vector_index": { | ||
| "provider": "milvus", |
Signed-off-by: Cheney Zhang <chen.zhang@zilliz.com>
d2de3ab to
6d40560
Compare
Author
|
Addressed the review items in 6d40560:
Validation:
|
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Milvus-backed external vector index provider for the in-memory metadata store.
This fresh branch replaces #404, which was based on an older storage/vector-index layout and now conflicts with current
main.What changed
VectorIndexand aMilvusVectorIndeximplementation usingpymilvus.MilvusClientvector_index.provider="milvus"config with URI, token, collection name, and dimension optionsinmemorymetadata backend for create, update, delete, clear, and similarity searchmilvuswith non-inmemorymetadata stores for now so the configured external index is not silently ignoredValidation
uv run ruff check src/memu/app/settings.py src/memu/database/factory.py src/memu/database/inmemory src/memu/database/vector_index tests/test_milvus_vector_index.py examples/milvus_vector_index.pyuv run ruff format --check src/memu/app/settings.py src/memu/database/factory.py src/memu/database/inmemory src/memu/database/vector_index tests/test_milvus_vector_index.py examples/milvus_vector_index.pyuv run mypy src/memu/app/settings.py src/memu/database/factory.py src/memu/database/inmemory src/memu/database/vector_indexuv run python -m pytest tests/test_milvus_vector_index.py tests/test_inmemory.py tests/test_backend_conformance.py