Home / Function/ get_input_schema() — langchain Function Reference

get_input_schema() — langchain Function Reference

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

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  7866ea60_3af0_a9b8_ebab_618c759e89c8["get_input_schema()"]
  c6a370e4_a02a_c56a_38eb_7ca734dcbfea["RunnableLambda"]
  7866ea60_3af0_a9b8_ebab_618c759e89c8 -->|defined in| c6a370e4_a02a_c56a_38eb_7ca734dcbfea
  4b92cace_dc70_6808_9c96_2880d0125ea4["get_graph()"]
  4b92cace_dc70_6808_9c96_2880d0125ea4 -->|calls| 7866ea60_3af0_a9b8_ebab_618c759e89c8
  255c479b_b9fa_44d8_4de5_2562051e06b5["get_name()"]
  7866ea60_3af0_a9b8_ebab_618c759e89c8 -->|calls| 255c479b_b9fa_44d8_4de5_2562051e06b5
  style 7866ea60_3af0_a9b8_ebab_618c759e89c8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/base.py lines 4669–4710

    def get_input_schema(self, config: RunnableConfig | None = None) -> type[BaseModel]:
        """The Pydantic schema for the input to this `Runnable`.

        Args:
            config: The config to use.

        Returns:
            The input schema for this `Runnable`.

        """
        func = getattr(self, "func", None) or self.afunc

        if isinstance(func, itemgetter):
            # This is terrible, but afaict it's not possible to access _items
            # on itemgetter objects, so we have to parse the repr
            items = str(func).replace("operator.itemgetter(", "")[:-1].split(", ")
            if all(
                item[0] == "'" and item[-1] == "'" and item != "''" for item in items
            ):
                fields = {item[1:-1]: (Any, ...) for item in items}
                # It's a dict, lol
                return create_model_v2(self.get_name("Input"), field_definitions=fields)
            module = getattr(func, "__module__", None)
            return create_model_v2(
                self.get_name("Input"),
                root=list[Any],
                # To create the schema, we need to provide the module
                # where the underlying function is defined.
                # This allows pydantic to resolve type annotations appropriately.
                module_name=module,
            )

        if self.InputType != Any:
            return super().get_input_schema(config)

        if dict_keys := get_function_first_arg_dict_keys(func):
            return create_model_v2(
                self.get_name("Input"),
                field_definitions=dict.fromkeys(dict_keys, (Any, ...)),
            )

        return super().get_input_schema(config)

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free