The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
Add embeding_dims param to FAISS (#2513)
Dev Khantcdb8dcdb9e01
diff --git a/mem0/configs/vector_stores/faiss.py b/mem0/configs/vector_stores/faiss.pyindex 064585c67..b77a8add3 100644--- a/mem0/configs/vector_stores/faiss.py+++ b/mem0/configs/vector_stores/faiss.py@@ -12,6 +12,7 @@ class FAISSConfig(BaseModel):normalize_L2: bool = Field(False, description="Whether to normalize L2 vectors (only applicable for euclidean distance)")+ embedding_model_dims: int = Field(1536, description="Dimension of the embedding vector")@model_validator(mode="before")@classmethoddiff --git a/mem0/vector_stores/faiss.py b/mem0/vector_stores/faiss.pyindex 9a129f129..34405a847 100644--- a/mem0/vector_stores/faiss.py+++ b/mem0/vector_stores/faiss.py@@ -35,6 +35,7 @@ class FAISS(VectorStoreBase):path: Optional[str] = None,distance_strategy: str = "euclidean",normalize_L2: bool = False,+ embedding_model_dims: int = 1536,):"""Initialize the FAISS vector store.@@ -51,6 +52,7 @@ class FAISS(VectorStoreBase):self.path = path or f"/tmp/faiss/{collection_name}"self.distance_strategy = distance_strategyself.normalize_L2 = normalize_L2+ self.embedding_model_dims = embedding_model_dims# Initialize storage structuresself.index = None@@ -145,13 +147,12 @@ class FAISS(VectorStoreBase):return results- def create_col(self, name: str, vector_size: int = 1536, distance: str = None):+ def create_col(self, name: str, distance: str = None):"""Create a new collection.Args:name (str): Name of the collection.- vector_size (int, optional): Dimensionality of vectors. Defaults to 1536.distance (str, optional): Distance metric to use. Overrides the distance_strategypassed during initialization. Defaults to None.@@ -162,9 +163,9 @@ class FAISS(VectorStoreBase):# Create index based on distance strategyif distance_strategy.lower() == "inner_product" or distance_strategy.lower() == "cosine":- self.index = faiss.IndexFlatIP(vector_size)+ self.index = faiss.IndexFlatIP(self.embedding_model_dims)else:- self.index = faiss.IndexFlatL2(vector_size)+ self.index = faiss.IndexFlatL2(self.embedding_model_dims)self.collection_name = namediff --git a/pyproject.toml b/pyproject.tomlindex e2187d138..b6474a82d 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "mem0ai"-version = "0.1.85"+version = "0.1.86"description = "Long-term memory for AI Agents"authors = ["Mem0 <[email protected]>"]exclude = [