Skip to content

Commit 2bb1932

Browse files
committed
feat(api): Add vector store file batches api
1 parent 4dbe059 commit 2bb1932

File tree

11 files changed

+1229
-23
lines changed

11 files changed

+1229
-23
lines changed

llama_stack/core/routing_tables/vector_dbs.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,65 @@ async def openai_delete_vector_store_file(
245245
vector_store_id=vector_store_id,
246246
file_id=file_id,
247247
)
248+
249+
async def openai_create_vector_store_file_batch(
250+
self,
251+
vector_store_id: str,
252+
file_ids: list[str],
253+
attributes: dict[str, Any] | None = None,
254+
chunking_strategy: Any | None = None,
255+
):
256+
await self.assert_action_allowed("update", "vector_db", vector_store_id)
257+
provider = await self.get_provider_impl(vector_store_id)
258+
return await provider.openai_create_vector_store_file_batch(
259+
vector_store_id=vector_store_id,
260+
file_ids=file_ids,
261+
attributes=attributes,
262+
chunking_strategy=chunking_strategy,
263+
)
264+
265+
async def openai_retrieve_vector_store_file_batch(
266+
self,
267+
batch_id: str,
268+
vector_store_id: str,
269+
):
270+
await self.assert_action_allowed("read", "vector_db", vector_store_id)
271+
provider = await self.get_provider_impl(vector_store_id)
272+
return await provider.openai_retrieve_vector_store_file_batch(
273+
batch_id=batch_id,
274+
vector_store_id=vector_store_id,
275+
)
276+
277+
async def openai_list_files_in_vector_store_file_batch(
278+
self,
279+
batch_id: str,
280+
vector_store_id: str,
281+
after: str | None = None,
282+
before: str | None = None,
283+
filter: str | None = None,
284+
limit: int | None = 20,
285+
order: str | None = "desc",
286+
):
287+
await self.assert_action_allowed("read", "vector_db", vector_store_id)
288+
provider = await self.get_provider_impl(vector_store_id)
289+
return await provider.openai_list_files_in_vector_store_file_batch(
290+
batch_id=batch_id,
291+
vector_store_id=vector_store_id,
292+
after=after,
293+
before=before,
294+
filter=filter,
295+
limit=limit,
296+
order=order,
297+
)
298+
299+
async def openai_cancel_vector_store_file_batch(
300+
self,
301+
batch_id: str,
302+
vector_store_id: str,
303+
):
304+
await self.assert_action_allowed("update", "vector_db", vector_store_id)
305+
provider = await self.get_provider_impl(vector_store_id)
306+
return await provider.openai_cancel_vector_store_file_batch(
307+
batch_id=batch_id,
308+
vector_store_id=vector_store_id,
309+
)

llama_stack/providers/inline/vector_io/faiss/faiss.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def __init__(self, config: FaissVectorIOConfig, inference_api: Inference, files_
206206
self.cache: dict[str, VectorDBWithIndex] = {}
207207
self.kvstore: KVStore | None = None
208208
self.openai_vector_stores: dict[str, dict[str, Any]] = {}
209+
self.openai_file_batches: dict[str, dict[str, Any]] = {}
209210

210211
async def initialize(self) -> None:
211212
self.kvstore = await kvstore_impl(self.config.kvstore)

llama_stack/providers/inline/vector_io/sqlite_vec/sqlite_vec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ def __init__(self, config, inference_api: Inference, files_api: Files | None) ->
415415
self.files_api = files_api
416416
self.cache: dict[str, VectorDBWithIndex] = {}
417417
self.openai_vector_stores: dict[str, dict[str, Any]] = {}
418+
self.openai_file_batches: dict[str, dict[str, Any]] = {}
418419
self.kvstore: KVStore | None = None
419420

420421
async def initialize(self) -> None:

llama_stack/providers/remote/vector_io/chroma/chroma.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ async def initialize(self) -> None:
166166
log.info(f"Connecting to Chroma local db at: {self.config.db_path}")
167167
self.client = chromadb.PersistentClient(path=self.config.db_path)
168168
self.openai_vector_stores = await self._load_openai_vector_stores()
169+
self.openai_file_batches: dict[str, dict[str, Any]] = {}
169170

170171
async def shutdown(self) -> None:
171172
pass

llama_stack/providers/remote/vector_io/milvus/milvus.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ def __init__(
317317
self.kvstore: KVStore | None = None
318318
self.vector_db_store = None
319319
self.openai_vector_stores: dict[str, dict[str, Any]] = {}
320+
self.openai_file_batches: dict[str, dict[str, Any]] = {}
320321
self.metadata_collection_name = "openai_vector_stores_metadata"
321322

322323
async def initialize(self) -> None:

llama_stack/providers/remote/vector_io/pgvector/pgvector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ def __init__(
353353
self.kvstore: KVStore | None = None
354354
self.vector_db_store = None
355355
self.openai_vector_stores: dict[str, dict[str, Any]] = {}
356+
self.openai_file_batches: dict[str, dict[str, Any]] = {}
356357
self.metadata_collection_name = "openai_vector_stores_metadata"
357358

358359
async def initialize(self) -> None:

llama_stack/providers/remote/vector_io/qdrant/qdrant.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def __init__(
170170
self.vector_db_store = None
171171
self.kvstore: KVStore | None = None
172172
self.openai_vector_stores: dict[str, dict[str, Any]] = {}
173+
self.openai_file_batches: dict[str, dict[str, Any]] = {}
173174
self._qdrant_lock = asyncio.Lock()
174175

175176
async def initialize(self) -> None:

llama_stack/providers/remote/vector_io/weaviate/weaviate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def __init__(
170170
self.kvstore: KVStore | None = None
171171
self.vector_db_store = None
172172
self.openai_vector_stores: dict[str, dict[str, Any]] = {}
173+
self.openai_file_batches: dict[str, dict[str, Any]] = {}
173174
self.metadata_collection_name = "openai_vector_stores_metadata"
174175

175176
def _get_client(self) -> weaviate.Client:

0 commit comments

Comments
 (0)