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
Speed up `_auto_encoder()` by 15% in `embedchain/helpers/json_serializable.py` (#1265)
Saurabh Misra622ed4a7c9b3
diff --git a/embedchain/helpers/json_serializable.py b/embedchain/helpers/json_serializable.pyindex bcbb4941f..656bb44bc 100644--- a/embedchain/helpers/json_serializable.py+++ b/embedchain/helpers/json_serializable.py@@ -97,10 +97,8 @@ class JSONSerializable:dict: A dictionary representation of the object."""if hasattr(obj, "__dict__"):- dct = obj.__dict__.copy()- for key, value in list(- dct.items()- ): # We use list() to get a copy of items to avoid dictionary size change during iteration.+ dct = {}+ for key, value in obj.__dict__.items():try:# Recursive: If the value is an instance of a subclass of JSONSerializable,# serialize it using the JSONSerializable serialize method.@@ -120,8 +118,9 @@ class JSONSerializable:# NOTE: Keep in mind that this logic needs to be applied to the decoder too.else:json.dumps(value) # Try to serialize the value.+ dct[key] = valueexcept TypeError:- del dct[key] # If it fails, remove the key-value pair from the dictionary.+ pass # If it fails, simply pass to skip this key-value pair of the dictionary.dct["__class__"] = obj.__class__.__name__return dct