Serializable base class.
This class is used to serialize objects to JSON.
It relies on the following methods and properties:
is_lc_serializable: Is this class serializable?
By design, even if a class inherits from Serializable, it is not serializable
by default. This is to prevent accidental serialization of objects that should
not be serialized.
get_lc_namespace: Get the namespace of the LangChain object.
During deserialization, this namespace is used to identify the correct class to instantiate.
Please see the Reviver class in langchain_core.load.load for more details.
During deserialization an additional mapping is handle classes that have moved or been renamed across package versions.
lc_secrets: A map of constructor argument names to secret ids.
lc_attributes: List of additional attribute names that should be included
as part of the serialized representation.
A map of constructor argument names to secret ids.
For example, {"openai_api_key": "OPENAI_API_KEY"}
List of attribute names that should be included in the serialized kwargs.
These attributes must be accepted by the constructor.
Default is an empty dictionary.
Is this class serializable?
By design, even if a class inherits from Serializable, it is not serializable
by default. This is to prevent accidental serialization of objects that should
not be serialized.
Get the namespace of the LangChain object.
The default implementation splits cls.__module__ on '.', e.g.
langchain_openai.chat_models becomes
["langchain_openai", "chat_models"]. This value is used by lc_id to
build the serialization identifier.
New partner packages should not override this method. The default
behavior is correct for any class whose module path already reflects
its package name. Some older packages (e.g. langchain-openai,
langchain-anthropic) override it to return a legacy-style namespace
like ["langchain", "chat_models", "openai"], matching the module
paths that existed before those integrations were split out of the
main langchain package. Those overrides are kept for
backwards-compatible deserialization; new packages should not copy them.
Deserialization mapping is handled separately by
SERIALIZABLE_MAPPING in langchain_core.load.mapping.
Return a unique identifier for this class for serialization purposes.
The unique identifier is a list of strings that describes the path to the object.
For example, for the class langchain.llms.openai.OpenAI, the id is
["langchain", "llms", "openai", "OpenAI"].
Serialize the object to JSON.
Serialize a "not implemented" object.