fix: use valid S3 entity index names (#5416)
Co-authored-by: Kartik <kartik.labhshetwar@mem0.ai>
This commit is contained in:
+7
-2
@@ -341,6 +341,11 @@ def _build_session_scope(filters):
|
||||
return "&".join(parts)
|
||||
|
||||
|
||||
def _entity_collection_name(provider: str, collection_name: str) -> str:
|
||||
separator = "-" if provider == "s3_vectors" else "_"
|
||||
return f"{collection_name}{separator}entities"
|
||||
|
||||
|
||||
setup_config()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -417,7 +422,7 @@ class Memory(MemoryBase):
|
||||
"""Lazily initialize entity store on first use."""
|
||||
if self._entity_store is None:
|
||||
entity_config = _safe_deepcopy_config(self.config.vector_store.config)
|
||||
entity_collection = f"{self.collection_name}_entities"
|
||||
entity_collection = _entity_collection_name(self.config.vector_store.provider, self.collection_name)
|
||||
# Set collection name on the cloned config
|
||||
if hasattr(entity_config, 'collection_name'):
|
||||
entity_config.collection_name = entity_collection
|
||||
@@ -1889,7 +1894,7 @@ class AsyncMemory(MemoryBase):
|
||||
"""Lazily initialize entity store on first use."""
|
||||
if self._entity_store is None:
|
||||
entity_config = _safe_deepcopy_config(self.config.vector_store.config)
|
||||
entity_collection = f"{self.collection_name}_entities"
|
||||
entity_collection = _entity_collection_name(self.config.vector_store.provider, self.collection_name)
|
||||
if hasattr(entity_config, 'collection_name'):
|
||||
entity_config.collection_name = entity_collection
|
||||
elif isinstance(entity_config, dict):
|
||||
|
||||
Reference in New Issue
Block a user