Home / Class/ BaseLLMOutputParser Class — langchain Architecture

BaseLLMOutputParser Class — langchain Architecture

Architecture documentation for the BaseLLMOutputParser class in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  525bc30a_8df1_d25e_75d9_aaed8bf6dc98["BaseLLMOutputParser"]
  92e0b9ea_b844_d40b_6560_e9c0b74a9278["base.py"]
  525bc30a_8df1_d25e_75d9_aaed8bf6dc98 -->|defined in| 92e0b9ea_b844_d40b_6560_e9c0b74a9278
  ed977dbe_388f_1e3d_b9dc_6b6244713930["parse_result()"]
  525bc30a_8df1_d25e_75d9_aaed8bf6dc98 -->|method| ed977dbe_388f_1e3d_b9dc_6b6244713930
  2be265b1_8102_c927_29aa_00e92f4c1e3f["aparse_result()"]
  525bc30a_8df1_d25e_75d9_aaed8bf6dc98 -->|method| 2be265b1_8102_c927_29aa_00e92f4c1e3f

Relationship Graph

Source Code

libs/core/langchain_core/output_parsers/base.py lines 30–67

class BaseLLMOutputParser(ABC, Generic[T]):
    """Abstract base class for parsing the outputs of a model."""

    @abstractmethod
    def parse_result(self, result: list[Generation], *, partial: bool = False) -> T:
        """Parse a list of candidate model `Generation` objects into a specific format.

        Args:
            result: A list of `Generation` to be parsed.

                The `Generation` objects are assumed to be different candidate outputs
                for a single model input.
            partial: Whether to parse the output as a partial result.

                This is useful for parsers that can parse partial results.

        Returns:
            Structured output.
        """

    async def aparse_result(
        self, result: list[Generation], *, partial: bool = False
    ) -> T:
        """Parse a list of candidate model `Generation` objects into a specific format.

        Args:
            result: A list of `Generation` to be parsed.

                The Generations are assumed to be different candidate outputs for a
                single model input.
            partial: Whether to parse the output as a partial result.

                This is useful for parsers that can parse partial results.

        Returns:
            Structured output.
        """
        return await run_in_executor(None, self.parse_result, result, partial=partial)

Frequently Asked Questions

What is the BaseLLMOutputParser class?
BaseLLMOutputParser is a class in the langchain codebase, defined in libs/core/langchain_core/output_parsers/base.py.
Where is BaseLLMOutputParser defined?
BaseLLMOutputParser is defined in libs/core/langchain_core/output_parsers/base.py at line 30.

Analyze Your Own Codebase

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

Try Supermodel Free