Home / Function/ parse_result() — langchain Function Reference

parse_result() — langchain Function Reference

Architecture documentation for the parse_result() function in json.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  06efbece_d7af_13f0_6b96_e81512502f42["parse_result()"]
  0d9a7db1_a024_a63e_d6da_4108a6cd2019["JsonOutputParser"]
  06efbece_d7af_13f0_6b96_e81512502f42 -->|defined in| 0d9a7db1_a024_a63e_d6da_4108a6cd2019
  7035eca2_a525_23ad_aece_91541acfef4a["parse()"]
  7035eca2_a525_23ad_aece_91541acfef4a -->|calls| 06efbece_d7af_13f0_6b96_e81512502f42
  06efbece_d7af_13f0_6b96_e81512502f42["parse_result()"]
  06efbece_d7af_13f0_6b96_e81512502f42 -->|calls| 06efbece_d7af_13f0_6b96_e81512502f42
  832ab0e8_f54d_dc1d_0342_eccf5c13bd0d["parse_result()"]
  832ab0e8_f54d_dc1d_0342_eccf5c13bd0d -->|calls| 06efbece_d7af_13f0_6b96_e81512502f42
  06efbece_d7af_13f0_6b96_e81512502f42["parse_result()"]
  06efbece_d7af_13f0_6b96_e81512502f42 -->|calls| 06efbece_d7af_13f0_6b96_e81512502f42
  style 06efbece_d7af_13f0_6b96_e81512502f42 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/output_parsers/json.py lines 61–91

    def parse_result(self, result: list[Generation], *, partial: bool = False) -> Any:
        """Parse the result of an LLM call to a JSON object.

        Args:
            result: The result of the LLM call.
            partial: Whether to parse partial JSON objects.

                If `True`, the output will be a JSON object containing all the keys that
                have been returned so far.

                If `False`, the output will be the full JSON object.

        Returns:
            The parsed JSON object.

        Raises:
            OutputParserException: If the output is not valid JSON.
        """
        text = result[0].text
        text = text.strip()
        if partial:
            try:
                return parse_json_markdown(text)
            except JSONDecodeError:
                return None
        else:
            try:
                return parse_json_markdown(text)
            except JSONDecodeError as e:
                msg = f"Invalid json output: {text}"
                raise OutputParserException(msg, llm_output=text) from e

Domain

Subdomains

Frequently Asked Questions

What does parse_result() do?
parse_result() is a function in the langchain codebase, defined in libs/core/langchain_core/output_parsers/json.py.
Where is parse_result() defined?
parse_result() is defined in libs/core/langchain_core/output_parsers/json.py at line 61.
What does parse_result() call?
parse_result() calls 1 function(s): parse_result.
What calls parse_result()?
parse_result() is called by 3 function(s): parse, parse_result, parse_result.

Analyze Your Own Codebase

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

Try Supermodel Free