Home / Function/ __init__() — langchain Function Reference

__init__() — langchain Function Reference

Architecture documentation for the __init__() function in exceptions.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fce3a01a_3f42_aea4_cfc7_64f82c3763a2["__init__()"]
  0dd75536_e009_da4d_0090_3d46069fce40["OutputParserException"]
  fce3a01a_3f42_aea4_cfc7_64f82c3763a2 -->|defined in| 0dd75536_e009_da4d_0090_3d46069fce40
  b15992ac_1154_1dc9_ebdf_37d385ad5198["create_message()"]
  fce3a01a_3f42_aea4_cfc7_64f82c3763a2 -->|calls| b15992ac_1154_1dc9_ebdf_37d385ad5198
  style fce3a01a_3f42_aea4_cfc7_64f82c3763a2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/exceptions.py lines 25–65

    def __init__(
        self,
        error: Any,
        observation: str | None = None,
        llm_output: str | None = None,
        send_to_llm: bool = False,  # noqa: FBT001,FBT002
    ):
        """Create an `OutputParserException`.

        Args:
            error: The error that's being re-raised or an error message.
            observation: String explanation of error which can be passed to a model to
                try and remediate the issue.
            llm_output: String model output which is error-ing.

            send_to_llm: Whether to send the observation and llm_output back to an Agent
                after an `OutputParserException` has been raised.

                This gives the underlying model driving the agent the context that the
                previous output was improperly structured, in the hopes that it will
                update the output to the correct format.

        Raises:
            ValueError: If `send_to_llm` is `True` but either observation or
                `llm_output` are not provided.
        """
        if isinstance(error, str):
            error = create_message(
                message=error, error_code=ErrorCode.OUTPUT_PARSING_FAILURE
            )

        super().__init__(error)
        if send_to_llm and (observation is None or llm_output is None):
            msg = (
                "Arguments 'observation' & 'llm_output'"
                " are required if 'send_to_llm' is True"
            )
            raise ValueError(msg)
        self.observation = observation
        self.llm_output = llm_output
        self.send_to_llm = send_to_llm

Domain

Subdomains

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/core/langchain_core/exceptions.py.
Where is __init__() defined?
__init__() is defined in libs/core/langchain_core/exceptions.py at line 25.
What does __init__() call?
__init__() calls 1 function(s): create_message.

Analyze Your Own Codebase

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

Try Supermodel Free