Home / Function/ _prepare_input() — langchain Function Reference

_prepare_input() — langchain Function Reference

Architecture documentation for the _prepare_input() function in eval_chain.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ee557ec3_4797_27ed_1453_0e5e54776464["_prepare_input()"]
  a58ec485_afe5_c733_6e70_92d4365f961c["ScoreStringEvalChain"]
  ee557ec3_4797_27ed_1453_0e5e54776464 -->|defined in| a58ec485_afe5_c733_6e70_92d4365f961c
  594dca8e_4d11_5ac3_44ac_def949ee07ff["_evaluate_strings()"]
  594dca8e_4d11_5ac3_44ac_def949ee07ff -->|calls| ee557ec3_4797_27ed_1453_0e5e54776464
  2a8e4ecd_7e90_d7b0_7098_e2e9ffbb9fb7["_aevaluate_strings()"]
  2a8e4ecd_7e90_d7b0_7098_e2e9ffbb9fb7 -->|calls| ee557ec3_4797_27ed_1453_0e5e54776464
  style ee557ec3_4797_27ed_1453_0e5e54776464 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/evaluation/scoring/eval_chain.py lines 296–320

    def _prepare_input(
        self,
        prediction: str,
        input_: str | None,
        reference: str | None,
    ) -> dict:
        """Prepare the input for the chain.

        Args:
            prediction: The output string from the first model.
            prediction_b: The output string from the second model.
            input_: The input or task string.
            reference: The reference string, if any.

        Returns:
            The prepared input for the chain.

        """
        input_dict = {
            "prediction": prediction,
            "input": input_,
        }
        if self.requires_reference:
            input_dict["reference"] = reference
        return input_dict

Domain

Subdomains

Frequently Asked Questions

What does _prepare_input() do?
_prepare_input() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/scoring/eval_chain.py.
Where is _prepare_input() defined?
_prepare_input() is defined in libs/langchain/langchain_classic/evaluation/scoring/eval_chain.py at line 296.
What calls _prepare_input()?
_prepare_input() is called by 2 function(s): _aevaluate_strings, _evaluate_strings.

Analyze Your Own Codebase

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

Try Supermodel Free