Home / Function/ prep_inputs() — langchain Function Reference

prep_inputs() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  d66dd3df_8d8d_1576_bf19_2f49fc27b7ec["prep_inputs()"]
  f3cef70e_11b0_61c9_7ec0_7308f4b45056["Chain"]
  d66dd3df_8d8d_1576_bf19_2f49fc27b7ec -->|defined in| f3cef70e_11b0_61c9_7ec0_7308f4b45056
  cbab652e_92a7_bf56_f96d_801fd5f6dacd["invoke()"]
  cbab652e_92a7_bf56_f96d_801fd5f6dacd -->|calls| d66dd3df_8d8d_1576_bf19_2f49fc27b7ec
  9ecc68a4_1a52_6816_7fd7_ca210db8af19["dict()"]
  d66dd3df_8d8d_1576_bf19_2f49fc27b7ec -->|calls| 9ecc68a4_1a52_6816_7fd7_ca210db8af19
  style d66dd3df_8d8d_1576_bf19_2f49fc27b7ec fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/base.py lines 521–543

    def prep_inputs(self, inputs: dict[str, Any] | Any) -> dict[str, str]:
        """Prepare chain inputs, including adding inputs from memory.

        Args:
            inputs: Dictionary of raw inputs, or single input if chain expects
                only one param. Should contain all inputs specified in
                `Chain.input_keys` except for inputs that will be set by the chain's
                memory.

        Returns:
            A dictionary of all inputs, including those added by the chain's memory.
        """
        if not isinstance(inputs, dict):
            _input_keys = set(self.input_keys)
            if self.memory is not None:
                # If there are multiple input keys, but some get set by memory so that
                # only one is not set, we can still figure out which key it is.
                _input_keys = _input_keys.difference(self.memory.memory_variables)
            inputs = {next(iter(_input_keys)): inputs}
        if self.memory is not None:
            external_context = self.memory.load_memory_variables(inputs)
            inputs = dict(inputs, **external_context)
        return inputs

Subdomains

Calls

Called By

Frequently Asked Questions

What does prep_inputs() do?
prep_inputs() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/base.py.
Where is prep_inputs() defined?
prep_inputs() is defined in libs/langchain/langchain_classic/chains/base.py at line 521.
What does prep_inputs() call?
prep_inputs() calls 1 function(s): dict.
What calls prep_inputs()?
prep_inputs() is called by 1 function(s): invoke.

Analyze Your Own Codebase

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

Try Supermodel Free