mirror of
https://github.com/james-m-jordan/morphik-core.git
synced 2025-05-09 19:32:38 +00:00
initialize vector store before multivector store
This commit is contained in:
parent
a34ef42aee
commit
79865f0bd1
23
core/api.py
23
core/api.py
@ -113,15 +113,30 @@ async def initialize_database():
|
||||
@app.on_event("startup")
|
||||
async def initialize_vector_store():
|
||||
"""Initialize vector store tables and indexes on application startup."""
|
||||
logger.info("Initializing vector store...")
|
||||
# First initialize the primary vector store (PGVectorStore if using pgvector)
|
||||
logger.info("Initializing primary vector store...")
|
||||
if hasattr(vector_store, 'initialize'):
|
||||
success = await vector_store.initialize()
|
||||
if success:
|
||||
logger.info("Vector store initialization successful")
|
||||
logger.info("Primary vector store initialization successful")
|
||||
else:
|
||||
logger.error("Vector store initialization failed")
|
||||
logger.error("Primary vector store initialization failed")
|
||||
else:
|
||||
logger.warning("Vector store does not have an initialize method")
|
||||
logger.warning("Primary vector store does not have an initialize method")
|
||||
|
||||
# Then initialize the multivector store if enabled
|
||||
if settings.ENABLE_COLPALI and colpali_vector_store:
|
||||
logger.info("Initializing multivector store...")
|
||||
# Handle both synchronous and asynchronous initialize methods
|
||||
if hasattr(colpali_vector_store.initialize, '__awaitable__'):
|
||||
success = await colpali_vector_store.initialize()
|
||||
else:
|
||||
success = colpali_vector_store.initialize()
|
||||
|
||||
if success:
|
||||
logger.info("Multivector store initialization successful")
|
||||
else:
|
||||
logger.error("Multivector store initialization failed")
|
||||
|
||||
# Initialize vector store
|
||||
match settings.VECTOR_STORE_PROVIDER:
|
||||
|
@ -77,8 +77,8 @@ class DocumentService:
|
||||
completion_model=completion_model,
|
||||
)
|
||||
|
||||
if colpali_vector_store:
|
||||
colpali_vector_store.initialize()
|
||||
# MultiVectorStore initialization is now handled in the FastAPI startup event
|
||||
# so we don't need to initialize it here again
|
||||
|
||||
# Cache-related data structures
|
||||
# Maps cache name to active cache object
|
||||
|
@ -35,7 +35,7 @@ class MultiVectorStore(BaseVectorStore):
|
||||
self.conn = None
|
||||
self.max_retries = max_retries
|
||||
self.retry_delay = retry_delay
|
||||
self.initialize()
|
||||
# Don't initialize here - initialization will be handled separately
|
||||
|
||||
@contextmanager
|
||||
def get_connection(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user