vibe.assistant.services.vector_store_manager¶
VectorStoreManager - manages OpenAI vector stores for reference document grounding.
This service handles: - Creating vector stores for template reference documents - Uploading PDF files to vector stores - Caching vector store IDs to avoid redundant uploads - Cache invalidation when source files change
Vector stores are keyed by template_id + hash of file contents, allowing automatic invalidation when reference documents are modified.
OpenAIClientProtocol ¶
Protocol for OpenAI client to enable testing without real API.
vector_stores ¶
vector_stores: VectorStoresProtocol
Access the vector_stores namespace for creating and managing stores.
VectorStoresProtocol ¶
Protocol for vector_stores namespace.
retrieve ¶
retrieve(vector_store_id: str) -> VectorStoreProtocol
Retrieve an existing vector store by ID.
VectorStoreProtocol ¶
Protocol for a vector store object.
VectorStoreFilesProtocol ¶
Protocol for vector_stores.files namespace.
upload_and_poll ¶
upload_and_poll(*, vector_store_id: str, file: object) -> None
Upload file to vector store and wait for processing to complete.
VectorStoreManager ¶
Manages vector store creation, caching, and file uploads.
Vector stores are keyed by template_id + hash of file contents, allowing automatic invalidation when reference documents change.
The manager uses a two-level cache: 1. In-memory cache for fast repeated lookups within a process 2. Persistent file-based cache for cross-process/restart persistence
__init__ ¶
__init__(client: OpenAIClientProtocol, cache_dir: Path) -> None
Initialize the vector store manager.
| Parameters: |
|
|---|
get_or_create_store ¶
get_or_create_store(template_id: str, file_paths: list[Path]) -> str
Get existing vector store or create new one for template files.
This method: 1. Computes a cache key from template_id and file content hashes 2. Checks in-memory cache for existing store ID 3. Checks persistent cache for existing store ID 4. Validates the store still exists in OpenAI 5. Creates new store if needed
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
clear_cache ¶
clear_cache() -> int
Clear all cached vector store mappings.
Note: This does NOT delete the vector stores from OpenAI, only the local cache. Useful for forcing re-creation.
| Returns: |
|
|---|