Home / Function/ InputType() — langchain Function Reference

InputType() — langchain Function Reference

Architecture documentation for the InputType() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  4d73bbad_82f7_d027_94fe_8412ac8e2b27["InputType()"]
  4a62481c_02cb_a5de_1833_50669d5351a6["Runnable"]
  4d73bbad_82f7_d027_94fe_8412ac8e2b27 -->|defined in| 4a62481c_02cb_a5de_1833_50669d5351a6
  255c479b_b9fa_44d8_4de5_2562051e06b5["get_name()"]
  4d73bbad_82f7_d027_94fe_8412ac8e2b27 -->|calls| 255c479b_b9fa_44d8_4de5_2562051e06b5
  style 4d73bbad_82f7_d027_94fe_8412ac8e2b27 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/base.py lines 300–332

    def InputType(self) -> type[Input]:  # noqa: N802
        """Input type.

        The type of input this `Runnable` accepts specified as a type annotation.

        Raises:
            TypeError: If the input type cannot be inferred.
        """
        # First loop through all parent classes and if any of them is
        # a Pydantic model, we will pick up the generic parameterization
        # from that model via the __pydantic_generic_metadata__ attribute.
        for base in self.__class__.mro():
            if hasattr(base, "__pydantic_generic_metadata__"):
                metadata = base.__pydantic_generic_metadata__
                if (
                    "args" in metadata
                    and len(metadata["args"]) == _RUNNABLE_GENERIC_NUM_ARGS
                ):
                    return cast("type[Input]", metadata["args"][0])

        # If we didn't find a Pydantic model in the parent classes,
        # then loop through __orig_bases__. This corresponds to
        # Runnables that are not pydantic models.
        for cls in self.__class__.__orig_bases__:  # type: ignore[attr-defined]
            type_args = get_args(cls)
            if type_args and len(type_args) == _RUNNABLE_GENERIC_NUM_ARGS:
                return cast("type[Input]", type_args[0])

        msg = (
            f"Runnable {self.get_name()} doesn't have an inferable InputType. "
            "Override the InputType property to specify the input type."
        )
        raise TypeError(msg)

Domain

Subdomains

Calls

Frequently Asked Questions

What does InputType() do?
InputType() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/base.py.
Where is InputType() defined?
InputType() is defined in libs/core/langchain_core/runnables/base.py at line 300.
What does InputType() call?
InputType() calls 1 function(s): get_name.

Analyze Your Own Codebase

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

Try Supermodel Free