Make Files API an optional dependency of faiss provider

Because we haven't updated every template to include a Files API
provider yet, this adjusts the Files API to be an optional dependency
instead of a required one of the Faiss provider.

Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
Ben Browning 2025-06-12 08:51:41 -04:00
parent 8a5ea57253
commit 46da232e83
4 changed files with 14 additions and 4 deletions

View file

@ -47,7 +47,7 @@ class OpenAIVectorStoreMixin(ABC):
# These should be provided by the implementing class
openai_vector_stores: dict[str, dict[str, Any]]
files_api: Files
files_api: Files | None
@abstractmethod
async def _save_openai_vector_store(self, store_id: str, store_info: dict[str, Any]) -> None:
@ -425,6 +425,14 @@ class OpenAIVectorStoreMixin(ABC):
vector_store_id=vector_store_id,
)
if not self.files_api:
vector_store_file_object.status = "failed"
vector_store_file_object.last_error = VectorStoreFileLastError(
code="server_error",
message="Files API is not available",
)
return vector_store_file_object
if isinstance(chunking_strategy, VectorStoreChunkingStrategyStatic):
max_chunk_size_tokens = chunking_strategy.static.max_chunk_size_tokens
chunk_overlap_tokens = chunking_strategy.static.chunk_overlap_tokens