Home / Function/ on_llm_error() — langchain Function Reference

on_llm_error() — langchain Function Reference

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

Function python Observability Tracers calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  3505d603_99c7_4f09_1b1a_6ff5f813e647["on_llm_error()"]
  0f6b3261_31fa_c34e_ca33_cb141bdf78ff["BaseTracer"]
  3505d603_99c7_4f09_1b1a_6ff5f813e647 -->|defined in| 0f6b3261_31fa_c34e_ca33_cb141bdf78ff
  4b401c00_96f1_b370_0600_e443d4f48b29["on_llm_error()"]
  4b401c00_96f1_b370_0600_e443d4f48b29 -->|calls| 3505d603_99c7_4f09_1b1a_6ff5f813e647
  9191b24f_a202_df21_16c5_e2608083aef8["_end_trace()"]
  3505d603_99c7_4f09_1b1a_6ff5f813e647 -->|calls| 9191b24f_a202_df21_16c5_e2608083aef8
  98d8d3b7_7fe9_0dba_121a_88efce1db2b8["_on_llm_error()"]
  3505d603_99c7_4f09_1b1a_6ff5f813e647 -->|calls| 98d8d3b7_7fe9_0dba_121a_88efce1db2b8
  4b401c00_96f1_b370_0600_e443d4f48b29["on_llm_error()"]
  3505d603_99c7_4f09_1b1a_6ff5f813e647 -->|calls| 4b401c00_96f1_b370_0600_e443d4f48b29
  style 3505d603_99c7_4f09_1b1a_6ff5f813e647 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tracers/base.py lines 214–238

    def on_llm_error(
        self,
        error: BaseException,
        *,
        run_id: UUID,
        **kwargs: Any,
    ) -> Run:
        """Handle an error for an LLM run.

        Args:
            error: The error.
            run_id: The run ID.
            **kwargs: Additional arguments.

        Returns:
            The run.
        """
        # "chat_model" is only used for the experimental new streaming_events format.
        # This change should not affect any existing tracers.
        llm_run = self._errored_llm_run(
            error=error, run_id=run_id, response=kwargs.pop("response", None)
        )
        self._end_trace(llm_run)
        self._on_llm_error(llm_run)
        return llm_run

Domain

Subdomains

Called By

Frequently Asked Questions

What does on_llm_error() do?
on_llm_error() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/base.py.
Where is on_llm_error() defined?
on_llm_error() is defined in libs/core/langchain_core/tracers/base.py at line 214.
What does on_llm_error() call?
on_llm_error() calls 3 function(s): _end_trace, _on_llm_error, on_llm_error.
What calls on_llm_error()?
on_llm_error() is called by 1 function(s): on_llm_error.

Analyze Your Own Codebase

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

Try Supermodel Free