Home / File/ serializable.py — langchain Source File

serializable.py — langchain Source File

Architecture documentation for serializable.py, a python file in the langchain codebase. 7 imports, 0 dependents.

File python CoreAbstractions Serialization 7 imports 5 functions 5 classes

Entity Profile

Dependency Diagram

graph LR
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4["serializable.py"]
  69e1d8cc_6173_dcd0_bfdf_2132d8e1ce56["contextlib"]
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 --> 69e1d8cc_6173_dcd0_bfdf_2132d8e1ce56
  2a7f66a7_8738_3d47_375b_70fcaa6ac169["logging"]
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 --> 2a7f66a7_8738_3d47_375b_70fcaa6ac169
  cccbe73e_4644_7211_4d55_e8fb133a8014["abc"]
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 --> cccbe73e_4644_7211_4d55_e8fb133a8014
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  d37712e8_0aaa_0e67_fe9c_15ba87012437["pydantic.fields"]
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 --> d37712e8_0aaa_0e67_fe9c_15ba87012437
  91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"]
  b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 --> 91721f45_4909_e489_8c1f_084f8bd87145
  style b5d5ce95_4e41_41ed_7fe6_1a936c2c18f4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Serializable base class."""

import contextlib
import logging
from abc import ABC
from typing import (
    Any,
    Literal,
    TypedDict,
    cast,
)

from pydantic import BaseModel, ConfigDict
from pydantic.fields import FieldInfo
from typing_extensions import NotRequired, override

logger = logging.getLogger(__name__)


class BaseSerialized(TypedDict):
    """Base class for serialized objects."""

    lc: int
    """The version of the serialization format."""
    id: list[str]
    """The unique identifier of the object."""
    name: NotRequired[str]
    """The name of the object."""
    graph: NotRequired[dict[str, Any]]
    """The graph of the object."""


class SerializedConstructor(BaseSerialized):
    """Serialized constructor."""

    type: Literal["constructor"]
    """The type of the object. Must be `'constructor'`."""
    kwargs: dict[str, Any]
    """The constructor arguments."""


class SerializedSecret(BaseSerialized):
    """Serialized secret."""

    type: Literal["secret"]
    """The type of the object. Must be `'secret'`."""


class SerializedNotImplemented(BaseSerialized):
    """Serialized not implemented."""

    type: Literal["not_implemented"]
    """The type of the object. Must be `'not_implemented'`."""
    repr: str | None
    """The representation of the object."""


def try_neq_default(value: Any, key: str, model: BaseModel) -> bool:
    """Try to determine if a value is different from the default.

// ... (316 more lines)

Subdomains

Dependencies

  • abc
  • contextlib
  • logging
  • pydantic
  • pydantic.fields
  • typing
  • typing_extensions

Frequently Asked Questions

What does serializable.py do?
serializable.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in serializable.py?
serializable.py defines 5 function(s): _is_field_useful, _replace_secrets, _try_neq_default, to_json_not_implemented, try_neq_default.
What does serializable.py depend on?
serializable.py imports 7 module(s): abc, contextlib, logging, pydantic, pydantic.fields, typing, typing_extensions.
Where is serializable.py in the architecture?
serializable.py is located at libs/core/langchain_core/load/serializable.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/langchain_core/load).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free