From 8cc4925f7d3dfbf61b70b4f6152fdc5789eb85f8 Mon Sep 17 00:00:00 2001 From: Varsha Date: Tue, 19 Aug 2025 10:01:23 -0700 Subject: [PATCH] chore: Enable keyword search for Milvus inline (#3073) # What does this PR do? With https://github.com/milvus-io/milvus-lite/pull/294 - Milvus Lite supports keyword search using BM25. While introducing keyword search we had explicitly disabled it for inline milvus. This PR removes the need for the check, and enables `inline::milvus` for tests. ## Test Plan Run llama stack with `inline::milvus` enabled: ``` pytest tests/integration/vector_io/test_openai_vector_stores.py::test_openai_vector_store_search_modes --stack-config=http://localhost:8321 --embedding-model=all-MiniLM-L6-v2 -v ``` ``` INFO 2025-08-07 17:06:20,932 tests.integration.conftest:64 tests: Setting DISABLE_CODE_SANDBOX=1 for macOS =========================================================================================== test session starts ============================================================================================ platform darwin -- Python 3.12.11, pytest-7.4.4, pluggy-1.5.0 -- /Users/vnarsing/miniconda3/envs/stack-client/bin/python cachedir: .pytest_cache metadata: {'Python': '3.12.11', 'Platform': 'macOS-14.7.6-arm64-arm-64bit', 'Packages': {'pytest': '7.4.4', 'pluggy': '1.5.0'}, 'Plugins': {'asyncio': '0.23.8', 'cov': '6.0.0', 'timeout': '2.2.0', 'socket': '0.7.0', 'html': '3.1.1', 'langsmith': '0.3.39', 'anyio': '4.8.0', 'metadata': '3.0.0'}} rootdir: /Users/vnarsing/go/src/github/meta-llama/llama-stack configfile: pyproject.toml plugins: asyncio-0.23.8, cov-6.0.0, timeout-2.2.0, socket-0.7.0, html-3.1.1, langsmith-0.3.39, anyio-4.8.0, metadata-3.0.0 asyncio: mode=Mode.AUTO collected 3 items tests/integration/vector_io/test_openai_vector_stores.py::test_openai_vector_store_search_modes[None-None-all-MiniLM-L6-v2-None-384-vector] PASSED [ 33%] tests/integration/vector_io/test_openai_vector_stores.py::test_openai_vector_store_search_modes[None-None-all-MiniLM-L6-v2-None-384-keyword] PASSED [ 66%] tests/integration/vector_io/test_openai_vector_stores.py::test_openai_vector_store_search_modes[None-None-all-MiniLM-L6-v2-None-384-hybrid] PASSED [100%] ============================================================================================ 3 passed in 4.75s ============================================================================================= ``` Signed-off-by: Varsha Prasad Narsing Co-authored-by: Francisco Arceo --- llama_stack/providers/remote/vector_io/milvus/milvus.py | 9 --------- pyproject.toml | 2 ++ tests/integration/vector_io/test_openai_vector_stores.py | 1 + uv.lock | 6 +++++- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/llama_stack/providers/remote/vector_io/milvus/milvus.py b/llama_stack/providers/remote/vector_io/milvus/milvus.py index 0eaae81b3..c659bdf6c 100644 --- a/llama_stack/providers/remote/vector_io/milvus/milvus.py +++ b/llama_stack/providers/remote/vector_io/milvus/milvus.py @@ -413,15 +413,6 @@ class MilvusVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorDBsProtocolP index = await self._get_and_cache_vector_db_index(vector_db_id) if not index: raise VectorStoreNotFoundError(vector_db_id) - - if params and params.get("mode") == "keyword": - # Check if this is inline Milvus (Milvus-Lite) - if hasattr(self.config, "db_path"): - raise NotImplementedError( - "Keyword search is not supported in Milvus-Lite. " - "Please use a remote Milvus server for keyword search functionality." - ) - return await index.query_chunks(query, params) async def delete_chunks(self, store_id: str, chunks_for_deletion: list[ChunkForDeletion]) -> None: diff --git a/pyproject.toml b/pyproject.toml index f02c02c41..a918c3e36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,6 +93,7 @@ unit = [ "blobfile", "faiss-cpu", "pymilvus>=2.5.12", + "milvus-lite>=2.5.0", "litellm", "together", "coverage", @@ -118,6 +119,7 @@ test = [ "sqlalchemy[asyncio]>=2.0.41", "requests", "pymilvus>=2.5.12", + "milvus-lite>=2.5.0", "weaviate-client>=4.16.4", ] docs = [ diff --git a/tests/integration/vector_io/test_openai_vector_stores.py b/tests/integration/vector_io/test_openai_vector_stores.py index 7ccca9077..bead95c26 100644 --- a/tests/integration/vector_io/test_openai_vector_stores.py +++ b/tests/integration/vector_io/test_openai_vector_stores.py @@ -56,6 +56,7 @@ def skip_if_provider_doesnt_support_openai_vector_stores_search(client_with_mode "keyword": [ "inline::sqlite-vec", "remote::milvus", + "inline::milvus", ], "hybrid": [ "inline::sqlite-vec", diff --git a/uv.lock b/uv.lock index 3e3bf7e24..0cb2164db 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.12" resolution-markers = [ "(python_full_version >= '3.13' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version >= '3.13' and sys_platform != 'darwin' and sys_platform != 'linux')", @@ -1809,6 +1809,7 @@ test = [ { name = "chardet" }, { name = "datasets" }, { name = "mcp" }, + { name = "milvus-lite" }, { name = "openai" }, { name = "pymilvus" }, { name = "pypdf" }, @@ -1831,6 +1832,7 @@ unit = [ { name = "faiss-cpu" }, { name = "litellm" }, { name = "mcp" }, + { name = "milvus-lite" }, { name = "ollama" }, { name = "openai" }, { name = "pymilvus" }, @@ -1925,6 +1927,7 @@ test = [ { name = "chardet" }, { name = "datasets" }, { name = "mcp" }, + { name = "milvus-lite", specifier = ">=2.5.0" }, { name = "openai" }, { name = "pymilvus", specifier = ">=2.5.12" }, { name = "pypdf" }, @@ -1946,6 +1949,7 @@ unit = [ { name = "faiss-cpu" }, { name = "litellm" }, { name = "mcp" }, + { name = "milvus-lite", specifier = ">=2.5.0" }, { name = "ollama" }, { name = "openai" }, { name = "pymilvus", specifier = ">=2.5.12" },