Home / File/ _types.py — anthropic-sdk-python Source File

_types.py — anthropic-sdk-python Source File

Architecture documentation for _types.py, a python file in the anthropic-sdk-python codebase. 9 imports, 3 dependents.

File python StreamProtocol SSEDecoder 9 imports 3 dependents 9 classes

Entity Profile

Dependency Diagram

graph LR
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0["_types.py"]
  d8af20ea_d6b2_e21a_499d_eb81af499916["types"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> d8af20ea_d6b2_e21a_499d_eb81af499916
  f7463bf1_ebe5_18ec_cc7d_af03d312451d["_models"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> f7463bf1_ebe5_18ec_cc7d_af03d312451d
  1a6768c9_bbca_e747_7ecf_5d7a1fe35633["_parse._response"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> 1a6768c9_bbca_e747_7ecf_5d7a1fe35633
  e2c4c315_43b6_9399_18d2_a13f4c810aa0["_utils._transform"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> e2c4c315_43b6_9399_18d2_a13f4c810aa0
  35760a8f_eed8_3e37_1cb0_1c263e212592["types.parsed_message"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> 35760a8f_eed8_3e37_1cb0_1c263e212592
  b3cc094d_9da6_ef71_d615_ea247382f1d9["types.citations_delta"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> b3cc094d_9da6_ef71_d615_ea247382f1d9
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> 37c05070_ca59_d596_7250_de9d1939227f
  9ba31bda_b3a7_3697_4f5b_cc7d6ca16e80["jiter"]
  0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 --> 9ba31bda_b3a7_3697_4f5b_cc7d6ca16e80
  0a07d1cd_f7c3_7747_3560_42a5b3d3bf48["__init__.py"]
  0a07d1cd_f7c3_7747_3560_42a5b3d3bf48 --> 0fe13bcd_521d_1fdd_3edc_21cd47da8ca0
  1e66b543_4a7a_c49e_b6a6_6343193fb272["_beta_messages.py"]
  1e66b543_4a7a_c49e_b6a6_6343193fb272 --> 0fe13bcd_521d_1fdd_3edc_21cd47da8ca0
  738ef0a0_4e16_ebf0_9c79_a17daa58ddef["_messages.py"]
  738ef0a0_4e16_ebf0_9c79_a17daa58ddef --> 0fe13bcd_521d_1fdd_3edc_21cd47da8ca0
  style 0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import TYPE_CHECKING, Any, Dict, Union, Generic, cast
from typing_extensions import List, Literal, Annotated

import jiter

from ...types import (
    Message,
    ContentBlock,
    MessageDeltaEvent as RawMessageDeltaEvent,
    MessageStartEvent as RawMessageStartEvent,
    RawMessageStopEvent,
    ContentBlockDeltaEvent as RawContentBlockDeltaEvent,
    ContentBlockStartEvent as RawContentBlockStartEvent,
    RawContentBlockStopEvent,
)
from ..._models import BaseModel, GenericModel
from .._parse._response import ResponseFormatT
from ..._utils._transform import PropertyInfo
from ...types.parsed_message import ParsedMessage, ParsedContentBlock
from ...types.citations_delta import Citation


class TextEvent(BaseModel):
    type: Literal["text"]

    text: str
    """The text delta"""

    snapshot: str
    """The entire accumulated text"""

    def parsed_snapshot(self) -> Dict[str, Any]:
        return cast(Dict[str, Any], jiter.from_json(self.snapshot.encode("utf-8"), partial_mode="trailing-strings"))


class CitationEvent(BaseModel):
    type: Literal["citation"]

    citation: Citation
    """The new citation"""

    snapshot: List[Citation]
    """All of the accumulated citations"""


class ThinkingEvent(BaseModel):
    type: Literal["thinking"]

    thinking: str
    """The thinking delta"""

    snapshot: str
    """The accumulated thinking so far"""


class SignatureEvent(BaseModel):
    type: Literal["signature"]

    signature: str
    """The signature of the thinking block"""
// ... (81 more lines)

Subdomains

Dependencies

  • _models
  • _parse._response
  • _utils._transform
  • jiter
  • types
  • types.citations_delta
  • types.parsed_message
  • typing
  • typing_extensions

Frequently Asked Questions

What does _types.py do?
_types.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the StreamProtocol domain, SSEDecoder subdomain.
What does _types.py depend on?
_types.py imports 9 module(s): _models, _parse._response, _utils._transform, jiter, types, types.citations_delta, types.parsed_message, typing, and 1 more.
What files import _types.py?
_types.py is imported by 3 file(s): __init__.py, _beta_messages.py, _messages.py.
Where is _types.py in the architecture?
_types.py is located at src/anthropic/lib/streaming/_types.py (domain: StreamProtocol, subdomain: SSEDecoder, directory: src/anthropic/lib/streaming).

Analyze Your Own Codebase

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

Try Supermodel Free