important fix

This commit is contained in:
Ashwin Bharambe 2025-10-20 19:54:25 -07:00
parent 86926ee339
commit 016388b788
5 changed files with 14 additions and 41 deletions

View file

@ -67,44 +67,16 @@ class VectorStoresRoutingTable(CommonRoutingTableImpl):
raise ModelNotFoundError(embedding_model) raise ModelNotFoundError(embedding_model)
if model.model_type != ModelType.embedding: if model.model_type != ModelType.embedding:
raise ModelTypeError(embedding_model, model.model_type, ModelType.embedding) raise ModelTypeError(embedding_model, model.model_type, ModelType.embedding)
if "embedding_dimension" not in model.metadata:
raise ValueError(f"Model {embedding_model} does not have an embedding dimension")
try: vector_store = VectorStoreWithOwner(
provider = self.impls_by_provider_id[provider_id] identifier=vector_store_id,
except KeyError: type=ResourceType.vector_store.value,
available_providers = list(self.impls_by_provider_id.keys())
raise ValueError(
f"Provider '{provider_id}' not found in routing table. Available providers: {available_providers}"
) from None
logger.warning(
"VectorStore is being deprecated in future releases in favor of VectorStore. Please migrate your usage accordingly."
)
request = OpenAICreateVectorStoreRequestWithExtraBody(
name=vector_store_name or vector_store_id,
embedding_model=embedding_model,
embedding_dimension=model.metadata["embedding_dimension"],
provider_id=provider_id, provider_id=provider_id,
provider_vector_store_id=provider_vector_store_id, provider_resource_id=provider_vector_store_id,
embedding_model=embedding_model,
embedding_dimension=embedding_dimension,
vector_store_name=vector_store_name,
) )
vector_store = await provider.openai_create_vector_store(request)
vector_store_id = vector_store.id
actual_provider_vector_store_id = provider_vector_store_id or vector_store_id
logger.warning(
f"Ignoring vector_store_id {vector_store_id} and using vector_store_id {vector_store_id} instead. Setting VectorStore {vector_store_id} to VectorStore.vector_store_name"
)
vector_store_data = {
"identifier": vector_store_id,
"type": ResourceType.vector_store.value,
"provider_id": provider_id,
"provider_resource_id": actual_provider_vector_store_id,
"embedding_model": embedding_model,
"embedding_dimension": model.metadata["embedding_dimension"],
"vector_store_name": vector_store.name,
}
vector_store = TypeAdapter(VectorStoreWithOwner).validate_python(vector_store_data)
await self.register_object(vector_store) await self.register_object(vector_store)
return vector_store return vector_store

View file

@ -242,7 +242,6 @@ class FaissVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProtoco
assert self.kvstore is not None assert self.kvstore is not None
if vector_store_id not in self.cache: if vector_store_id not in self.cache:
logger.warning(f"Vector DB {vector_store_id} not found")
return return
await self.cache[vector_store_id].index.delete() await self.cache[vector_store_id].index.delete()

View file

@ -443,7 +443,6 @@ class SQLiteVecVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresPro
async def unregister_vector_store(self, vector_store_id: str) -> None: async def unregister_vector_store(self, vector_store_id: str) -> None:
if vector_store_id not in self.cache: if vector_store_id not in self.cache:
logger.warning(f"Vector DB {vector_store_id} not found")
return return
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]

View file

@ -333,7 +333,7 @@ class OpenAIVectorStoreMixin(ABC):
@abstractmethod @abstractmethod
async def insert_chunks( async def insert_chunks(
self, self,
vector_store_id: str, vector_db_id: str,
chunks: list[Chunk], chunks: list[Chunk],
ttl_seconds: int | None = None, ttl_seconds: int | None = None,
) -> None: ) -> None:
@ -342,7 +342,7 @@ class OpenAIVectorStoreMixin(ABC):
@abstractmethod @abstractmethod
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:
"""Query chunks from a vector database (provider-specific implementation).""" """Query chunks from a vector database (provider-specific implementation)."""
pass pass
@ -619,7 +619,7 @@ class OpenAIVectorStoreMixin(ABC):
# TODO: Add support for ranking_options.ranker # TODO: Add support for ranking_options.ranker
response = await self.query_chunks( response = await self.query_chunks(
vector_store_id=vector_store_id, vector_db_id=vector_store_id,
query=search_query, query=search_query,
params=params, params=params,
) )
@ -813,7 +813,7 @@ class OpenAIVectorStoreMixin(ABC):
) )
else: else:
await self.insert_chunks( await self.insert_chunks(
vector_store_id=vector_store_id, vector_db_id=vector_store_id,
chunks=chunks, chunks=chunks,
) )
vector_store_file_object.status = "completed" vector_store_file_object.status = "completed"

View file

@ -37,6 +37,9 @@ def pytest_sessionstart(session):
if "LLAMA_STACK_TEST_INFERENCE_MODE" not in os.environ: if "LLAMA_STACK_TEST_INFERENCE_MODE" not in os.environ:
os.environ["LLAMA_STACK_TEST_INFERENCE_MODE"] = "replay" os.environ["LLAMA_STACK_TEST_INFERENCE_MODE"] = "replay"
if "LLAMA_STACK_LOGGING" not in os.environ:
os.environ["LLAMA_STACK_LOGGING"] = "all=warning"
if "SQLITE_STORE_DIR" not in os.environ: if "SQLITE_STORE_DIR" not in os.environ:
os.environ["SQLITE_STORE_DIR"] = tempfile.mkdtemp() os.environ["SQLITE_STORE_DIR"] = tempfile.mkdtemp()