fix(vector_stores): deep-copy Redis DEFAULT_FIELDS so instances keep distinct dims (#5633)

This commit is contained in:
Yash Singh
2026-06-22 11:29:25 +05:30
committed by GitHub
parent 650b734b1b
commit a48f34cf77
2 changed files with 58 additions and 4 deletions
+5 -3
View File
@@ -1,3 +1,4 @@
import copy
import json
import logging
from datetime import datetime, timezone
@@ -65,7 +66,7 @@ class RedisDB(VectorStoreBase):
"prefix": f"mem0:{collection_name}",
}
fields = DEFAULT_FIELDS.copy()
fields = copy.deepcopy(DEFAULT_FIELDS)
fields[-1]["attrs"]["dims"] = embedding_model_dims
self.schema = {"index": index_schema, "fields": fields}
@@ -98,8 +99,9 @@ class RedisDB(VectorStoreBase):
"prefix": f"mem0:{collection_name}",
}
# Copy the default fields and update the vector field with the specified dimensions
fields = DEFAULT_FIELDS.copy()
# Deep-copy the default fields so mutating the nested vector attrs never
# leaks into the module global or other instances.
fields = copy.deepcopy(DEFAULT_FIELDS)
fields[-1]["attrs"]["dims"] = embedding_dims
fields[-1]["attrs"]["distance_metric"] = distance_metric