mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-12 04:00:42 +00:00
revert insert_chunks and query_chunks
This commit is contained in:
parent
04b9954a8b
commit
86926ee339
9 changed files with 53 additions and 53 deletions
|
|
@ -249,19 +249,19 @@ class FaissVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProtoco
|
||||||
del self.cache[vector_store_id]
|
del self.cache[vector_store_id]
|
||||||
await self.kvstore.delete(f"{VECTOR_DBS_PREFIX}{vector_store_id}")
|
await self.kvstore.delete(f"{VECTOR_DBS_PREFIX}{vector_store_id}")
|
||||||
|
|
||||||
async def insert_chunks(self, vector_store_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
async def insert_chunks(self, vector_db_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
||||||
index = self.cache.get(vector_store_id)
|
index = self.cache.get(vector_db_id)
|
||||||
if index is None:
|
if index is None:
|
||||||
raise ValueError(f"Vector DB {vector_store_id} not found. found: {self.cache.keys()}")
|
raise ValueError(f"Vector DB {vector_db_id} not found. found: {self.cache.keys()}")
|
||||||
|
|
||||||
await index.insert_chunks(chunks)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self, vector_store_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
self, vector_db_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
index = self.cache.get(vector_store_id)
|
index = self.cache.get(vector_db_id)
|
||||||
if index is None:
|
if index is None:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
|
|
||||||
return await index.query_chunks(query, params)
|
return await index.query_chunks(query, params)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -448,20 +448,20 @@ class SQLiteVecVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresPro
|
||||||
await self.cache[vector_store_id].index.delete()
|
await self.cache[vector_store_id].index.delete()
|
||||||
del self.cache[vector_store_id]
|
del self.cache[vector_store_id]
|
||||||
|
|
||||||
async def insert_chunks(self, vector_store_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
async def insert_chunks(self, vector_db_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
# The VectorStoreWithIndex helper is expected to compute embeddings via the inference_api
|
# The VectorStoreWithIndex helper is expected to compute embeddings via the inference_api
|
||||||
# and then call our index's add_chunks.
|
# and then call our index's add_chunks.
|
||||||
await index.insert_chunks(chunks)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self, vector_store_id: str, query: Any, params: dict[str, Any] | None = None
|
self, vector_db_id: str, query: Any, params: dict[str, Any] | None = None
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
return await index.query_chunks(query, params)
|
return await index.query_chunks(query, params)
|
||||||
|
|
||||||
async def delete_chunks(self, store_id: str, chunks_for_deletion: list[ChunkForDeletion]) -> None:
|
async def delete_chunks(self, store_id: str, chunks_for_deletion: list[ChunkForDeletion]) -> None:
|
||||||
|
|
|
||||||
|
|
@ -169,20 +169,20 @@ class ChromaVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProtoc
|
||||||
await self.cache[vector_store_id].index.delete()
|
await self.cache[vector_store_id].index.delete()
|
||||||
del self.cache[vector_store_id]
|
del self.cache[vector_store_id]
|
||||||
|
|
||||||
async def insert_chunks(self, vector_store_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
async def insert_chunks(self, vector_db_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if index is None:
|
if index is None:
|
||||||
raise ValueError(f"Vector DB {vector_store_id} not found in Chroma")
|
raise ValueError(f"Vector DB {vector_db_id} not found in Chroma")
|
||||||
|
|
||||||
await index.insert_chunks(chunks)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self, vector_store_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
self, vector_db_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
|
|
||||||
if index is None:
|
if index is None:
|
||||||
raise ValueError(f"Vector DB {vector_store_id} not found in Chroma")
|
raise ValueError(f"Vector DB {vector_db_id} not found in Chroma")
|
||||||
|
|
||||||
return await index.query_chunks(query, params)
|
return await index.query_chunks(query, params)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -348,19 +348,19 @@ class MilvusVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProtoc
|
||||||
await self.cache[vector_store_id].index.delete()
|
await self.cache[vector_store_id].index.delete()
|
||||||
del self.cache[vector_store_id]
|
del self.cache[vector_store_id]
|
||||||
|
|
||||||
async def insert_chunks(self, vector_store_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
async def insert_chunks(self, vector_db_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
|
|
||||||
await index.insert_chunks(chunks)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self, vector_store_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
self, vector_db_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
return await index.query_chunks(query, params)
|
return await index.query_chunks(query, params)
|
||||||
|
|
||||||
async def delete_chunks(self, store_id: str, chunks_for_deletion: list[ChunkForDeletion]) -> None:
|
async def delete_chunks(self, store_id: str, chunks_for_deletion: list[ChunkForDeletion]) -> None:
|
||||||
|
|
|
||||||
|
|
@ -399,14 +399,14 @@ class PGVectorVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProt
|
||||||
assert self.kvstore is not None
|
assert self.kvstore is not None
|
||||||
await self.kvstore.delete(key=f"{VECTOR_DBS_PREFIX}{vector_store_id}")
|
await self.kvstore.delete(key=f"{VECTOR_DBS_PREFIX}{vector_store_id}")
|
||||||
|
|
||||||
async def insert_chunks(self, vector_store_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
async def insert_chunks(self, vector_db_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
await index.insert_chunks(chunks)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self, vector_store_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
self, vector_db_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
return await index.query_chunks(query, params)
|
return await index.query_chunks(query, params)
|
||||||
|
|
||||||
async def _get_and_cache_vector_store_index(self, vector_store_id: str) -> VectorStoreWithIndex:
|
async def _get_and_cache_vector_store_index(self, vector_store_id: str) -> VectorStoreWithIndex:
|
||||||
|
|
|
||||||
|
|
@ -222,19 +222,19 @@ class QdrantVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProtoc
|
||||||
self.cache[vector_store_id] = index
|
self.cache[vector_store_id] = index
|
||||||
return index
|
return index
|
||||||
|
|
||||||
async def insert_chunks(self, vector_store_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
async def insert_chunks(self, vector_db_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
|
|
||||||
await index.insert_chunks(chunks)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self, vector_store_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
self, vector_db_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
|
|
||||||
return await index.query_chunks(query, params)
|
return await index.query_chunks(query, params)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -366,19 +366,19 @@ class WeaviateVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, NeedsRequestProv
|
||||||
self.cache[vector_store_id] = index
|
self.cache[vector_store_id] = index
|
||||||
return index
|
return index
|
||||||
|
|
||||||
async def insert_chunks(self, vector_store_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
async def insert_chunks(self, vector_db_id: str, chunks: list[Chunk], ttl_seconds: int | None = None) -> None:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
|
|
||||||
await index.insert_chunks(chunks)
|
await index.insert_chunks(chunks)
|
||||||
|
|
||||||
async def query_chunks(
|
async def query_chunks(
|
||||||
self, vector_store_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
self, vector_db_id: str, query: InterleavedContent, params: dict[str, Any] | None = None
|
||||||
) -> QueryChunksResponse:
|
) -> QueryChunksResponse:
|
||||||
index = await self._get_and_cache_vector_store_index(vector_store_id)
|
index = await self._get_and_cache_vector_store_index(vector_db_id)
|
||||||
if not index:
|
if not index:
|
||||||
raise VectorStoreNotFoundError(vector_store_id)
|
raise VectorStoreNotFoundError(vector_db_id)
|
||||||
|
|
||||||
return await index.query_chunks(query, params)
|
return await index.query_chunks(query, params)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ def test_openai_vector_store_with_chunks(
|
||||||
|
|
||||||
# Insert chunks using the native LlamaStack API (since OpenAI API doesn't have direct chunk insertion)
|
# Insert chunks using the native LlamaStack API (since OpenAI API doesn't have direct chunk insertion)
|
||||||
llama_client.vector_io.insert(
|
llama_client.vector_io.insert(
|
||||||
vector_store_id=vector_store.id,
|
vector_db_id=vector_store.id,
|
||||||
chunks=sample_chunks,
|
chunks=sample_chunks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -434,7 +434,7 @@ def test_openai_vector_store_search_relevance(
|
||||||
|
|
||||||
# Insert chunks using native API
|
# Insert chunks using native API
|
||||||
llama_client.vector_io.insert(
|
llama_client.vector_io.insert(
|
||||||
vector_store_id=vector_store.id,
|
vector_db_id=vector_store.id,
|
||||||
chunks=sample_chunks,
|
chunks=sample_chunks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -484,7 +484,7 @@ def test_openai_vector_store_search_with_ranking_options(
|
||||||
|
|
||||||
# Insert chunks
|
# Insert chunks
|
||||||
llama_client.vector_io.insert(
|
llama_client.vector_io.insert(
|
||||||
vector_store_id=vector_store.id,
|
vector_db_id=vector_store.id,
|
||||||
chunks=sample_chunks,
|
chunks=sample_chunks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -544,7 +544,7 @@ def test_openai_vector_store_search_with_high_score_filter(
|
||||||
|
|
||||||
# Insert chunks
|
# Insert chunks
|
||||||
llama_client.vector_io.insert(
|
llama_client.vector_io.insert(
|
||||||
vector_store_id=vector_store.id,
|
vector_db_id=vector_store.id,
|
||||||
chunks=sample_chunks,
|
chunks=sample_chunks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -610,7 +610,7 @@ def test_openai_vector_store_search_with_max_num_results(
|
||||||
|
|
||||||
# Insert chunks
|
# Insert chunks
|
||||||
llama_client.vector_io.insert(
|
llama_client.vector_io.insert(
|
||||||
vector_store_id=vector_store.id,
|
vector_db_id=vector_store.id,
|
||||||
chunks=sample_chunks,
|
chunks=sample_chunks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1175,7 +1175,7 @@ def test_openai_vector_store_search_modes(
|
||||||
)
|
)
|
||||||
|
|
||||||
client_with_models.vector_io.insert(
|
client_with_models.vector_io.insert(
|
||||||
vector_store_id=vector_store.id,
|
vector_db_id=vector_store.id,
|
||||||
chunks=sample_chunks,
|
chunks=sample_chunks,
|
||||||
)
|
)
|
||||||
query = "Python programming language"
|
query = "Python programming language"
|
||||||
|
|
|
||||||
|
|
@ -123,12 +123,12 @@ def test_insert_chunks(
|
||||||
actual_vector_store_id = create_response.id
|
actual_vector_store_id = create_response.id
|
||||||
|
|
||||||
client_with_empty_registry.vector_io.insert(
|
client_with_empty_registry.vector_io.insert(
|
||||||
vector_store_id=actual_vector_store_id,
|
vector_db_id=actual_vector_store_id,
|
||||||
chunks=sample_chunks,
|
chunks=sample_chunks,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = client_with_empty_registry.vector_io.query(
|
response = client_with_empty_registry.vector_io.query(
|
||||||
vector_store_id=actual_vector_store_id,
|
vector_db_id=actual_vector_store_id,
|
||||||
query="What is the capital of France?",
|
query="What is the capital of France?",
|
||||||
)
|
)
|
||||||
assert response is not None
|
assert response is not None
|
||||||
|
|
@ -137,7 +137,7 @@ def test_insert_chunks(
|
||||||
|
|
||||||
query, expected_doc_id = test_case
|
query, expected_doc_id = test_case
|
||||||
response = client_with_empty_registry.vector_io.query(
|
response = client_with_empty_registry.vector_io.query(
|
||||||
vector_store_id=actual_vector_store_id,
|
vector_db_id=actual_vector_store_id,
|
||||||
query=query,
|
query=query,
|
||||||
)
|
)
|
||||||
assert response is not None
|
assert response is not None
|
||||||
|
|
@ -174,13 +174,13 @@ def test_insert_chunks_with_precomputed_embeddings(
|
||||||
]
|
]
|
||||||
|
|
||||||
client_with_empty_registry.vector_io.insert(
|
client_with_empty_registry.vector_io.insert(
|
||||||
vector_store_id=actual_vector_store_id,
|
vector_db_id=actual_vector_store_id,
|
||||||
chunks=chunks_with_embeddings,
|
chunks=chunks_with_embeddings,
|
||||||
)
|
)
|
||||||
|
|
||||||
provider = [p.provider_id for p in client_with_empty_registry.providers.list() if p.api == "vector_io"][0]
|
provider = [p.provider_id for p in client_with_empty_registry.providers.list() if p.api == "vector_io"][0]
|
||||||
response = client_with_empty_registry.vector_io.query(
|
response = client_with_empty_registry.vector_io.query(
|
||||||
vector_store_id=actual_vector_store_id,
|
vector_db_id=actual_vector_store_id,
|
||||||
query="precomputed embedding test",
|
query="precomputed embedding test",
|
||||||
params=vector_io_provider_params_dict.get(provider, None),
|
params=vector_io_provider_params_dict.get(provider, None),
|
||||||
)
|
)
|
||||||
|
|
@ -224,13 +224,13 @@ def test_query_returns_valid_object_when_identical_to_embedding_in_vdb(
|
||||||
]
|
]
|
||||||
|
|
||||||
client_with_empty_registry.vector_io.insert(
|
client_with_empty_registry.vector_io.insert(
|
||||||
vector_store_id=actual_vector_store_id,
|
vector_db_id=actual_vector_store_id,
|
||||||
chunks=chunks_with_embeddings,
|
chunks=chunks_with_embeddings,
|
||||||
)
|
)
|
||||||
|
|
||||||
provider = [p.provider_id for p in client_with_empty_registry.providers.list() if p.api == "vector_io"][0]
|
provider = [p.provider_id for p in client_with_empty_registry.providers.list() if p.api == "vector_io"][0]
|
||||||
response = client_with_empty_registry.vector_io.query(
|
response = client_with_empty_registry.vector_io.query(
|
||||||
vector_store_id=actual_vector_store_id,
|
vector_db_id=actual_vector_store_id,
|
||||||
query="duplicate",
|
query="duplicate",
|
||||||
params=vector_io_provider_params_dict.get(provider, None),
|
params=vector_io_provider_params_dict.get(provider, None),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue