diff --git a/docs/v0x/components/vectordbs/dbs/opensearch.mdx b/docs/v0x/components/vectordbs/dbs/opensearch.mdx index 4c0a729022..6eab4e127a 100644 --- a/docs/v0x/components/vectordbs/dbs/opensearch.mdx +++ b/docs/v0x/components/vectordbs/dbs/opensearch.mdx @@ -42,12 +42,19 @@ config = { "host": "your-domain.us-west-2.aoss.amazonaws.com", "port": 443, "http_auth": auth, - "embedding_model_dims": 1024, + "embedding_model_dims": 1536, # should match embedder's dimensions "connection_class": RequestsHttpConnection, "pool_maxsize": 20, "use_ssl": True, "verify_certs": True } + }, + "embedder": { + "provider": "openai", + "config": { + "model": "text-embedding-3-small", + "embedding_dims": 1536 + } } } ``` diff --git a/mem0/utils/factory.py b/mem0/utils/factory.py index ab3fc77a3c..b9bfe70415 100644 --- a/mem0/utils/factory.py +++ b/mem0/utils/factory.py @@ -192,6 +192,10 @@ class VectorStoreFactory: def create(cls, provider_name, config): class_type = cls.provider_to_class.get(provider_name) if class_type: + # Ensure the config includes embedding_model_dims, using the default from VectorStoreBase if not defined + if "embedding_model_dims" not in config: + from mem0.vector_stores.base import VectorStoreBase + config["embedding_model_dims"] = VectorStoreBase.embedding_model_dims if not isinstance(config, dict): config = config.model_dump() vector_store_instance = load_class(class_type) diff --git a/mem0/vector_stores/base.py b/mem0/vector_stores/base.py index 3e22499d79..e025d6275b 100644 --- a/mem0/vector_stores/base.py +++ b/mem0/vector_stores/base.py @@ -2,6 +2,7 @@ class VectorStoreBase(ABC): + embedding_model_dims = 1536 # Default value for embedding model dimensions which aligns with default OpenAI embedder dimensions @abstractmethod def create_col(self, name, vector_size, distance): """Create a new collection."""