Home / File/ schema.py — langchain Source File

schema.py — langchain Source File

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

File python CoreAbstractions MessageSchema 3 imports 1 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  8fc54027_af2e_acf9_1479_472ebaa69eb5["schema.py"]
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  8fc54027_af2e_acf9_1479_472ebaa69eb5 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"]
  8fc54027_af2e_acf9_1479_472ebaa69eb5 --> 91721f45_4909_e489_8c1f_084f8bd87145
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  8fc54027_af2e_acf9_1479_472ebaa69eb5 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  style 8fc54027_af2e_acf9_1479_472ebaa69eb5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Module contains typedefs that are used with `Runnable` objects."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Literal

from typing_extensions import NotRequired, TypedDict

if TYPE_CHECKING:
    from collections.abc import Sequence


class EventData(TypedDict, total=False):
    """Data associated with a streaming event."""

    input: Any
    """The input passed to the `Runnable` that generated the event.

    Inputs will sometimes be available at the *START* of the `Runnable`, and
    sometimes at the *END* of the `Runnable`.

    If a `Runnable` is able to stream its inputs, then its input by definition
    won't be known until the *END* of the `Runnable` when it has finished streaming
    its inputs.
    """
    error: NotRequired[BaseException]
    """The error that occurred during the execution of the `Runnable`.

    This field is only available if the `Runnable` raised an exception.

    !!! version-added "Added in `langchain-core` 1.0.0"
    """
    output: Any
    """The output of the `Runnable` that generated the event.

    Outputs will only be available at the *END* of the `Runnable`.

    For most `Runnable` objects, this field can be inferred from the `chunk` field,
    though there might be some exceptions for special a cased `Runnable` (e.g., like
    chat models), which may return more information.
    """
    chunk: Any
    """A streaming chunk from the output that generated the event.

    chunks support addition in general, and adding them up should result
    in the output of the `Runnable` that generated the event.
    """
    tool_call_id: NotRequired[str | None]
    """The tool call ID associated with the tool execution.

    This field is available for the `on_tool_error` event and can be used to
    link errors to specific tool calls in stateless agent implementations.
    """


class BaseStreamEvent(TypedDict):
    """Streaming event.

    Schema of a streaming event which is produced from the `astream_events` method.

// ... (129 more lines)

Subdomains

Functions

Dependencies

  • collections.abc
  • typing
  • typing_extensions

Frequently Asked Questions

What does schema.py do?
schema.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in schema.py?
schema.py defines 1 function(s): collections.
What does schema.py depend on?
schema.py imports 3 module(s): collections.abc, typing, typing_extensions.
Where is schema.py in the architecture?
schema.py is located at libs/core/langchain_core/runnables/schema.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/langchain_core/runnables).

Analyze Your Own Codebase

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

Try Supermodel Free