Home / Class/ RunnableEachBase Class — langchain Architecture

RunnableEachBase Class — langchain Architecture

Architecture documentation for the RunnableEachBase class in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  57d89d1d_02b3_8d07_62df_d426afea67e6["RunnableEachBase"]
  5f3c1f1c_6f8a_e293_7cb5_97c21b4bf214["base.py"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|defined in| 5f3c1f1c_6f8a_e293_7cb5_97c21b4bf214
  294ebcf6_de4d_8bbc_cbdc_bde70614a665["InputType()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| 294ebcf6_de4d_8bbc_cbdc_bde70614a665
  15765326_e4eb_0253_ee74_747067c70575["get_input_schema()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| 15765326_e4eb_0253_ee74_747067c70575
  06f7f066_b0ff_58f4_0924_a5671f6a0715["OutputType()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| 06f7f066_b0ff_58f4_0924_a5671f6a0715
  c8f84beb_54c9_9a75_664b_b24052c3dcc4["get_output_schema()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| c8f84beb_54c9_9a75_664b_b24052c3dcc4
  2696869e_de91_12bc_cd8e_23403d7ff5dc["config_specs()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| 2696869e_de91_12bc_cd8e_23403d7ff5dc
  ec9b0734_835b_8c2d_d154_142ad25cd33d["get_graph()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| ec9b0734_835b_8c2d_d154_142ad25cd33d
  db9610e5_43d9_a0fe_2809_573b256a983f["is_lc_serializable()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| db9610e5_43d9_a0fe_2809_573b256a983f
  7f72105e_4ad8_bc28_d265_d7f25acaecff["get_lc_namespace()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| 7f72105e_4ad8_bc28_d265_d7f25acaecff
  8c2120b6_0baf_9877_a062_c77f6888658e["_invoke()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| 8c2120b6_0baf_9877_a062_c77f6888658e
  fe1f96de_7965_fc9d_26ac_0ac55d889bc4["invoke()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| fe1f96de_7965_fc9d_26ac_0ac55d889bc4
  ff0ccdad_95ba_83de_17ee_1400efd821b1["_ainvoke()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| ff0ccdad_95ba_83de_17ee_1400efd821b1
  f5a7c343_3a99_16d5_9eee_8f53f742079d["ainvoke()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| f5a7c343_3a99_16d5_9eee_8f53f742079d
  31c30aef_fa76_cf3e_c203_9edba3dd04b1["astream_events()"]
  57d89d1d_02b3_8d07_62df_d426afea67e6 -->|method| 31c30aef_fa76_cf3e_c203_9edba3dd04b1

Relationship Graph

Source Code

libs/core/langchain_core/runnables/base.py lines 5272–5410

class RunnableEachBase(RunnableSerializable[list[Input], list[Output]]):
    """RunnableEachBase class.

    `Runnable` that calls another `Runnable` for each element of the input sequence.

    Use only if creating a new `RunnableEach` subclass with different `__init__`
    args.

    See documentation for `RunnableEach` for more details.

    """

    bound: Runnable[Input, Output]

    model_config = ConfigDict(
        arbitrary_types_allowed=True,
    )

    @property
    @override
    def InputType(self) -> Any:
        return list[self.bound.InputType]  # type: ignore[name-defined]

    @override
    def get_input_schema(self, config: RunnableConfig | None = None) -> type[BaseModel]:
        return create_model_v2(
            self.get_name("Input"),
            root=(
                list[self.bound.get_input_schema(config)],  # type: ignore[misc]
                None,
            ),
            # create model needs access to appropriate type annotations to be
            # able to construct the Pydantic model.
            # When we create the model, we pass information about the namespace
            # where the model is being created, so the type annotations can
            # be resolved correctly as well.
            # self.__class__.__module__ handles the case when the Runnable is
            # being sub-classed in a different module.
            module_name=self.__class__.__module__,
        )

    @property
    @override
    def OutputType(self) -> type[list[Output]]:
        return list[self.bound.OutputType]  # type: ignore[name-defined]

    @override
    def get_output_schema(
        self, config: RunnableConfig | None = None
    ) -> type[BaseModel]:
        schema = self.bound.get_output_schema(config)
        return create_model_v2(
            self.get_name("Output"),
            root=list[schema],  # type: ignore[valid-type]
            # create model needs access to appropriate type annotations to be
            # able to construct the Pydantic model.
            # When we create the model, we pass information about the namespace
            # where the model is being created, so the type annotations can
            # be resolved correctly as well.
            # self.__class__.__module__ handles the case when the Runnable is
            # being sub-classed in a different module.
            module_name=self.__class__.__module__,
        )

    @property
    @override
    def config_specs(self) -> list[ConfigurableFieldSpec]:
        return self.bound.config_specs

    @override
    def get_graph(self, config: RunnableConfig | None = None) -> Graph:
        return self.bound.get_graph(config)

    @classmethod
    @override
    def is_lc_serializable(cls) -> bool:
        """Return `True` as this class is serializable."""
        return True

    @classmethod
    @override

Frequently Asked Questions

What is the RunnableEachBase class?
RunnableEachBase is a class in the langchain codebase, defined in libs/core/langchain_core/runnables/base.py.
Where is RunnableEachBase defined?
RunnableEachBase is defined in libs/core/langchain_core/runnables/base.py at line 5272.

Analyze Your Own Codebase

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

Try Supermodel Free