Home / Function/ _evaluate_strings() — langchain Function Reference

_evaluate_strings() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  4021fe41_65d3_6fa7_5d31_3efed7bb0c71["_evaluate_strings()"]
  909e1aca_7c35_c9d5_2f9b_81064d86d9e6["JsonEqualityEvaluator"]
  4021fe41_65d3_6fa7_5d31_3efed7bb0c71 -->|defined in| 909e1aca_7c35_c9d5_2f9b_81064d86d9e6
  5524730f_9608_c667_bf87_2f343457eefb["_evaluate_strings()"]
  5524730f_9608_c667_bf87_2f343457eefb -->|calls| 4021fe41_65d3_6fa7_5d31_3efed7bb0c71
  7793dc6c_9c60_a7a0_ca86_d11624937249["_parse_json()"]
  4021fe41_65d3_6fa7_5d31_3efed7bb0c71 -->|calls| 7793dc6c_9c60_a7a0_ca86_d11624937249
  5524730f_9608_c667_bf87_2f343457eefb["_evaluate_strings()"]
  4021fe41_65d3_6fa7_5d31_3efed7bb0c71 -->|calls| 5524730f_9608_c667_bf87_2f343457eefb
  style 4021fe41_65d3_6fa7_5d31_3efed7bb0c71 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/evaluation/parsing/base.py lines 158–181

    def _evaluate_strings(
        self,
        prediction: str,
        reference: str | None = None,
        **kwargs: Any,
    ) -> dict:
        """Evaluate the prediction string.

        Args:
            prediction: The prediction string to evaluate.
            reference: The reference string to compare against.
            **kwargs: Additional keyword arguments (not used).

        Returns:
            `dict` containing the evaluation score.
        """
        parsed = self._parse_json(prediction)
        label = self._parse_json(cast("str", reference))
        if isinstance(label, list):
            if not isinstance(parsed, list):
                return {"score": 0}
            parsed = sorted(parsed, key=str)
            label = sorted(label, key=str)
        return {"score": self.operator(parsed, label)}

Domain

Subdomains

Frequently Asked Questions

What does _evaluate_strings() do?
_evaluate_strings() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/parsing/base.py.
Where is _evaluate_strings() defined?
_evaluate_strings() is defined in libs/langchain/langchain_classic/evaluation/parsing/base.py at line 158.
What does _evaluate_strings() call?
_evaluate_strings() calls 2 function(s): _evaluate_strings, _parse_json.
What calls _evaluate_strings()?
_evaluate_strings() is called by 1 function(s): _evaluate_strings.

Analyze Your Own Codebase

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

Try Supermodel Free