Home / File/ core.py — langchain Source File

core.py — langchain Source File

Architecture documentation for core.py, a python file in the langchain codebase. 14 imports, 0 dependents.

File python CoreAbstractions RunnableInterface 14 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  f4021fab_f34e_b0c4_272d_54fcccd4097b["core.py"]
  2a7f66a7_8738_3d47_375b_70fcaa6ac169["logging"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> 2a7f66a7_8738_3d47_375b_70fcaa6ac169
  bfa79181_b1e6_eba2_0d8e_9ddb8d3b949c["traceback"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> bfa79181_b1e6_eba2_0d8e_9ddb8d3b949c
  cccbe73e_4644_7211_4d55_e8fb133a8014["abc"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> cccbe73e_4644_7211_4d55_e8fb133a8014
  af34f08b_0ede_2b87_0db6_983d74ed0249["datetime"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> af34f08b_0ede_2b87_0db6_983d74ed0249
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  75137834_4ba7_dc43_7ec5_182c05eceedf["langchain_core.exceptions"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> 75137834_4ba7_dc43_7ec5_182c05eceedf
  36cce5da_d805_04c3_7e86_e1b4dd49b497["langchain_core.load"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> 36cce5da_d805_04c3_7e86_e1b4dd49b497
  17e2fb09_6b0f_338f_1319_77bc43602969["langchain_core.tracers.schemas"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> 17e2fb09_6b0f_338f_1319_77bc43602969
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  8dfa0cac_d802_3ccd_f710_43a5e70da3a5["uuid"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> 8dfa0cac_d802_3ccd_f710_43a5e70da3a5
  30db3e5b_4549_fdf8_eed3_1cfd8cacbe56["tenacity"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> 30db3e5b_4549_fdf8_eed3_1cfd8cacbe56
  c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> c554676d_b731_47b2_a98f_c1c2d537c0aa
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> d758344f_537f_649e_f467_b9d7442e86df
  ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"]
  f4021fab_f34e_b0c4_272d_54fcccd4097b --> ac2a9b92_4484_491e_1b48_ec85e71e1d58
  style f4021fab_f34e_b0c4_272d_54fcccd4097b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Utilities for the root listener."""

from __future__ import annotations

import logging
import traceback
from abc import ABC, abstractmethod
from datetime import datetime, timezone
from typing import (
    TYPE_CHECKING,
    Any,
    Literal,
    cast,
)

from langchain_core.exceptions import TracerException
from langchain_core.load import dumpd
from langchain_core.tracers.schemas import Run

if TYPE_CHECKING:
    from collections.abc import Coroutine, Sequence
    from uuid import UUID

    from tenacity import RetryCallState

    from langchain_core.documents import Document
    from langchain_core.messages import BaseMessage
    from langchain_core.outputs import (
        ChatGeneration,
        ChatGenerationChunk,
        GenerationChunk,
        LLMResult,
    )

logger = logging.getLogger(__name__)

SCHEMA_FORMAT_TYPE = Literal["original", "streaming_events"]


class _TracerCore(ABC):
    """Abstract base class for tracers.

    This class provides common methods, and reusable methods for tracers.
    """

    log_missing_parent: bool = True

    def __init__(
        self,
        *,
        _schema_format: Literal[
            "original", "streaming_events", "original+chat"
        ] = "original",
        **kwargs: Any,
    ) -> None:
        """Initialize the tracer.

        Args:
            _schema_format: Primarily changes how the inputs and outputs are handled.

// ... (646 more lines)

Subdomains

Functions

Classes

Dependencies

  • abc
  • collections.abc
  • datetime
  • langchain_core.documents
  • langchain_core.exceptions
  • langchain_core.load
  • langchain_core.messages
  • langchain_core.outputs
  • langchain_core.tracers.schemas
  • logging
  • tenacity
  • traceback
  • typing
  • uuid

Frequently Asked Questions

What does core.py do?
core.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in core.py?
core.py defines 1 function(s): collections.
What does core.py depend on?
core.py imports 14 module(s): abc, collections.abc, datetime, langchain_core.documents, langchain_core.exceptions, langchain_core.load, langchain_core.messages, langchain_core.outputs, and 6 more.
Where is core.py in the architecture?
core.py is located at libs/core/langchain_core/tracers/core.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/core/langchain_core/tracers).

Analyze Your Own Codebase

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

Try Supermodel Free