_beta_messages.py — anthropic-sdk-python Source File
Architecture documentation for _beta_messages.py, a python file in the anthropic-sdk-python codebase. 27 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 1e66b543_4a7a_c49e_b6a6_6343193fb272["_beta_messages.py"] 0fe13bcd_521d_1fdd_3edc_21cd47da8ca0["_types.py"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> 0fe13bcd_521d_1fdd_3edc_21cd47da8ca0 e07c5fdf_8abe_8389_4a76_d5d0afb02821["_utils"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> e07c5fdf_8abe_8389_4a76_d5d0afb02821 f7463bf1_ebe5_18ec_cc7d_af03d312451d["_models"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> f7463bf1_ebe5_18ec_cc7d_af03d312451d 6ae52b2b_b80e_bd13_d3c7_f2409e8d863a["_beta_types.py"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> 6ae52b2b_b80e_bd13_d3c7_f2409e8d863a cfda2285_ce65_17bd_c732_31fed9a72631["BetaCitationEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> cfda2285_ce65_17bd_c732_31fed9a72631 b8a0d204_5e44_6a66_589a_0173224fa9a2["BetaThinkingEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> b8a0d204_5e44_6a66_589a_0173224fa9a2 bf0f76d1_9437_1c74_6fe8_1c27d7289da9["BetaInputJsonEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> bf0f76d1_9437_1c74_6fe8_1c27d7289da9 28aa65ae_46ec_d6b5_61e6_696cfbfa7764["BetaSignatureEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> 28aa65ae_46ec_d6b5_61e6_696cfbfa7764 438ac573_78c1_54ae_8945_e202fbbf6a56["BetaCompactionEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> 438ac573_78c1_54ae_8945_e202fbbf6a56 3f86bd19_a51f_cc40_9859_e79ee601f0f3["ParsedBetaTextEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> 3f86bd19_a51f_cc40_9859_e79ee601f0f3 af372729_8819_55f4_4be0_6d25338c31c2["ParsedBetaMessageStopEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> af372729_8819_55f4_4be0_6d25338c31c2 32ecacf8_fc41_03a6_0188_9523091d029a["ParsedBetaContentBlockStopEvent"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> 32ecacf8_fc41_03a6_0188_9523091d029a c3e7c071_e102_f915_e24c_2a05dc6fb82d["_streaming"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> c3e7c071_e102_f915_e24c_2a05dc6fb82d cca712e6_75cf_6203_3b5a_ca9ff687f929["types.beta"] 1e66b543_4a7a_c49e_b6a6_6343193fb272 --> cca712e6_75cf_6203_3b5a_ca9ff687f929 style 1e66b543_4a7a_c49e_b6a6_6343193fb272 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import builtins
from types import TracebackType
from typing import TYPE_CHECKING, Any, Type, Generic, Callable, cast
from typing_extensions import Self, Iterator, Awaitable, AsyncIterator, assert_never
import httpx
from pydantic import BaseModel
from anthropic.types.beta.beta_tool_use_block import BetaToolUseBlock
from anthropic.types.beta.beta_mcp_tool_use_block import BetaMCPToolUseBlock
from anthropic.types.beta.beta_server_tool_use_block import BetaServerToolUseBlock
from ..._types import NOT_GIVEN, NotGiven
from ..._utils import consume_sync_iterator, consume_async_iterator
from ..._models import build, construct_type, construct_type_unchecked
from ._beta_types import (
BetaCitationEvent,
BetaThinkingEvent,
BetaInputJsonEvent,
BetaSignatureEvent,
BetaCompactionEvent,
ParsedBetaTextEvent,
ParsedBetaMessageStopEvent,
ParsedBetaMessageStreamEvent,
ParsedBetaContentBlockStopEvent,
)
from ..._streaming import Stream, AsyncStream
from ...types.beta import BetaRawMessageStreamEvent
from ..._utils._utils import is_given
from .._parse._response import ResponseFormatT, parse_text
from ...types.beta.parsed_beta_message import ParsedBetaMessage, ParsedBetaContentBlock
class BetaMessageStream(Generic[ResponseFormatT]):
text_stream: Iterator[str]
"""Iterator over just the text deltas in the stream.
```py
for text in stream.text_stream:
print(text, end="", flush=True)
print()
```
"""
def __init__(
self,
raw_stream: Stream[BetaRawMessageStreamEvent],
output_format: ResponseFormatT | NotGiven,
) -> None:
self._raw_stream = raw_stream
self.text_stream = self.__stream_text__()
self._iterator = self.__stream__()
self.__final_message_snapshot: ParsedBetaMessage[ResponseFormatT] | None = None
self.__output_format = output_format
@property
def response(self) -> httpx.Response:
return self._raw_stream.response
// ... (496 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- BetaCitationEvent
- BetaCompactionEvent
- BetaInputJsonEvent
- BetaSignatureEvent
- BetaThinkingEvent
- ParsedBetaContentBlockStopEvent
- ParsedBetaMessageStopEvent
- ParsedBetaTextEvent
- _beta_types.py
- _models
- _parse._response
- _streaming
- _types.py
- _utils
- _utils._utils
- anthropic.types.beta.beta_mcp_tool_use_block
- anthropic.types.beta.beta_server_tool_use_block
- anthropic.types.beta.beta_tool_use_block
- builtins
- httpx
- jiter
- pydantic
- types
- types.beta
- types.beta.parsed_beta_message
- typing
- typing_extensions
Imported By
Source
Frequently Asked Questions
What does _beta_messages.py do?
_beta_messages.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the StreamProtocol domain, AsyncStreaming subdomain.
What functions are defined in _beta_messages.py?
_beta_messages.py defines 2 function(s): accumulate_event, build_events.
What does _beta_messages.py depend on?
_beta_messages.py imports 27 module(s): BetaCitationEvent, BetaCompactionEvent, BetaInputJsonEvent, BetaSignatureEvent, BetaThinkingEvent, ParsedBetaContentBlockStopEvent, ParsedBetaMessageStopEvent, ParsedBetaTextEvent, and 19 more.
What files import _beta_messages.py?
_beta_messages.py is imported by 1 file(s): __init__.py.
Where is _beta_messages.py in the architecture?
_beta_messages.py is located at src/anthropic/lib/streaming/_beta_messages.py (domain: StreamProtocol, subdomain: AsyncStreaming, 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