fix: mongodb lazy initialization

This commit is contained in:
Young Han 2025-10-31 13:42:31 -07:00
parent cac2912ce6
commit 308f0d133a

View file

@ -420,12 +420,14 @@ class MongoDBVectorIOAdapter(OpenAIVectorStoreMixin, VectorIO, VectorStoresProto
if self.config.persistence: if self.config.persistence:
self.kvstore = await kvstore_impl(self.config.persistence) self.kvstore = await kvstore_impl(self.config.persistence)
# Validate connection string # Skip MongoDB connection if no connection string provided
# This allows other providers to work without MongoDB credentials
if not self.config.connection_string: if not self.config.connection_string:
raise ValueError( logger.warning(
"MongoDB connection_string is required but not provided. " "MongoDB connection_string not provided. "
"Please set MONGODB_CONNECTION_STRING environment variable or provide it in config." "MongoDB vector store will not be available until credentials are configured."
) )
return
# Connect to MongoDB with optimized settings for RAG # Connect to MongoDB with optimized settings for RAG
self.client = MongoClient( self.client = MongoClient(