Home / Function/ _parse_message_from_event() — anthropic-sdk-python Function Reference

_parse_message_from_event() — anthropic-sdk-python Function Reference

Architecture documentation for the _parse_message_from_event() function in _stream_decoder.py from the anthropic-sdk-python codebase.

Function python AnthropicClient SyncAPI calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  21cf148e_e403_27d0_043f_c464fcb60144["_parse_message_from_event()"]
  582aef90_700e_ea04_755a_159b23a192d2["AWSEventStreamDecoder"]
  21cf148e_e403_27d0_043f_c464fcb60144 -->|defined in| 582aef90_700e_ea04_755a_159b23a192d2
  b59cc883_d079_ab3c_26db_78fb47b9bde5["iter_bytes()"]
  b59cc883_d079_ab3c_26db_78fb47b9bde5 -->|calls| 21cf148e_e403_27d0_043f_c464fcb60144
  6c6b9845_9f62_9ee7_a980_1bf61dfd29ec["aiter_bytes()"]
  6c6b9845_9f62_9ee7_a980_1bf61dfd29ec -->|calls| 21cf148e_e403_27d0_043f_c464fcb60144
  60da91e1_bd97_ca34_0e9c_56eeffda1fe1["get_response_stream_shape()"]
  21cf148e_e403_27d0_043f_c464fcb60144 -->|calls| 60da91e1_bd97_ca34_0e9c_56eeffda1fe1
  style 21cf148e_e403_27d0_043f_c464fcb60144 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/lib/bedrock/_stream_decoder.py lines 54–64

    def _parse_message_from_event(self, event: EventStreamMessage) -> str | None:
        response_dict = event.to_response_dict()
        parsed_response = self.parser.parse(response_dict, get_response_stream_shape())
        if response_dict["status_code"] != 200:
            raise ValueError(f"Bad response code, expected 200: {response_dict}")

        chunk = parsed_response.get("chunk")
        if not chunk:
            return None

        return chunk.get("bytes").decode()  # type: ignore[no-any-return]

Subdomains

Frequently Asked Questions

What does _parse_message_from_event() do?
_parse_message_from_event() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/bedrock/_stream_decoder.py.
Where is _parse_message_from_event() defined?
_parse_message_from_event() is defined in src/anthropic/lib/bedrock/_stream_decoder.py at line 54.
What does _parse_message_from_event() call?
_parse_message_from_event() calls 1 function(s): get_response_stream_shape.
What calls _parse_message_from_event()?
_parse_message_from_event() is called by 2 function(s): aiter_bytes, iter_bytes.

Analyze Your Own Codebase

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

Try Supermodel Free