Home / Function/ prep_outputs() — langchain Function Reference

prep_outputs() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  e60bffb7_c7fe_f9f9_1671_b444e79457ef["prep_outputs()"]
  f3cef70e_11b0_61c9_7ec0_7308f4b45056["Chain"]
  e60bffb7_c7fe_f9f9_1671_b444e79457ef -->|defined in| f3cef70e_11b0_61c9_7ec0_7308f4b45056
  cbab652e_92a7_bf56_f96d_801fd5f6dacd["invoke()"]
  cbab652e_92a7_bf56_f96d_801fd5f6dacd -->|calls| e60bffb7_c7fe_f9f9_1671_b444e79457ef
  e74a56f1_f5d9_1683_0e44_ce6fd51d40b8["_validate_outputs()"]
  e60bffb7_c7fe_f9f9_1671_b444e79457ef -->|calls| e74a56f1_f5d9_1683_0e44_ce6fd51d40b8
  style e60bffb7_c7fe_f9f9_1671_b444e79457ef fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/base.py lines 471–494

    def prep_outputs(
        self,
        inputs: dict[str, str],
        outputs: dict[str, str],
        return_only_outputs: bool = False,  # noqa: FBT001,FBT002
    ) -> dict[str, str]:
        """Validate and prepare chain outputs, and save info about this run to memory.

        Args:
            inputs: Dictionary of chain inputs, including any inputs added by chain
                memory.
            outputs: Dictionary of initial chain outputs.
            return_only_outputs: Whether to only return the chain outputs. If `False`,
                inputs are also added to the final outputs.

        Returns:
            A dict of the final chain outputs.
        """
        self._validate_outputs(outputs)
        if self.memory is not None:
            self.memory.save_context(inputs, outputs)
        if return_only_outputs:
            return outputs
        return {**inputs, **outputs}

Subdomains

Called By

Frequently Asked Questions

What does prep_outputs() do?
prep_outputs() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/base.py.
Where is prep_outputs() defined?
prep_outputs() is defined in libs/langchain/langchain_classic/chains/base.py at line 471.
What does prep_outputs() call?
prep_outputs() calls 1 function(s): _validate_outputs.
What calls prep_outputs()?
prep_outputs() 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