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

parsed_beta_message.py — anthropic-sdk-python Source File

Architecture documentation for parsed_beta_message.py, a python file in the anthropic-sdk-python codebase. 31 imports, 1 dependents.

File python AnthropicClient AsyncAPI 31 imports 1 dependents 2 classes

Entity Profile

Dependency Diagram

graph LR
  91a19aea_7483_201a_3b9c_ae2833f7373f["parsed_beta_message.py"]
  40a4d499_6b34_0763_5e68_275c9212420c["_utils"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 40a4d499_6b34_0763_5e68_275c9212420c
  20977b2a_1890_cfe8_7dca_f3846f5fda73["beta_message.py"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 20977b2a_1890_cfe8_7dca_f3846f5fda73
  0da6889b_9352_8c02_9f21_a1deb1bdab0f["BetaMessage"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 0da6889b_9352_8c02_9f21_a1deb1bdab0f
  4877ad46_3c86_d7b4_2b96_7cbeafa65a2c["beta_text_block.py"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 4877ad46_3c86_d7b4_2b96_7cbeafa65a2c
  4f11b8ba_bf54_4d45_93e0_97854c533b42["BetaTextBlock"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 4f11b8ba_bf54_4d45_93e0_97854c533b42
  4d45177c_cd68_9cf6_7269_5aa30e08620d["beta_thinking_block.py"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 4d45177c_cd68_9cf6_7269_5aa30e08620d
  14284f68_a16b_5655_c891_8e911637e31c["BetaThinkingBlock"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 14284f68_a16b_5655_c891_8e911637e31c
  3490cc9c_a0ed_ccc0_0bf0_903998b3ac1a["beta_tool_use_block.py"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 3490cc9c_a0ed_ccc0_0bf0_903998b3ac1a
  5de6d66f_5988_4224_e724_578c556a4586["BetaToolUseBlock"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 5de6d66f_5988_4224_e724_578c556a4586
  eeb205f4_56e4_0c7d_ec9a_883c09629c6e["beta_compaction_block.py"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> eeb205f4_56e4_0c7d_ec9a_883c09629c6e
  45bc31e7_8b22_58b3_dd1d_30336abd100f["BetaCompactionBlock"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 45bc31e7_8b22_58b3_dd1d_30336abd100f
  9d21dca0_edd9_a04e_2d73_fa2c73d7f8ae["beta_mcp_tool_use_block.py"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 9d21dca0_edd9_a04e_2d73_fa2c73d7f8ae
  1cd1de5c_c735_016b_c0ae_3be63ad95b6f["BetaMCPToolUseBlock"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 1cd1de5c_c735_016b_c0ae_3be63ad95b6f
  774aa6ad_6c0d_d8ed_9ac4_90e4567b6f6d["beta_mcp_tool_result_block.py"]
  91a19aea_7483_201a_3b9c_ae2833f7373f --> 774aa6ad_6c0d_d8ed_9ac4_90e4567b6f6d
  style 91a19aea_7483_201a_3b9c_ae2833f7373f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

from typing import TYPE_CHECKING, List, Union, Generic, Optional
from typing_extensions import TypeVar, Annotated, TypeAlias

from ..._utils import PropertyInfo
from .beta_message import BetaMessage
from .beta_text_block import BetaTextBlock
from .beta_thinking_block import BetaThinkingBlock
from .beta_tool_use_block import BetaToolUseBlock
from .beta_compaction_block import BetaCompactionBlock
from .beta_mcp_tool_use_block import BetaMCPToolUseBlock
from .beta_mcp_tool_result_block import BetaMCPToolResultBlock
from .beta_server_tool_use_block import BetaServerToolUseBlock
from .beta_container_upload_block import BetaContainerUploadBlock
from .beta_redacted_thinking_block import BetaRedactedThinkingBlock
from .beta_web_search_tool_result_block import BetaWebSearchToolResultBlock
from .beta_code_execution_tool_result_block import BetaCodeExecutionToolResultBlock
from .beta_bash_code_execution_tool_result_block import BetaBashCodeExecutionToolResultBlock
from .beta_text_editor_code_execution_tool_result_block import BetaTextEditorCodeExecutionToolResultBlock

ResponseFormatT = TypeVar("ResponseFormatT", default=None)


__all__ = [
    "ParsedBetaTextBlock",
    "ParsedBetaContentBlock",
    "ParsedBetaMessage",
]


class ParsedBetaTextBlock(BetaTextBlock, Generic[ResponseFormatT]):
    parsed_output: Optional[ResponseFormatT] = None

    __api_exclude__ = {"parsed_output"}


# Note that generic unions are not valid for pydantic at runtime
ParsedBetaContentBlock: TypeAlias = Annotated[
    Union[
        ParsedBetaTextBlock[ResponseFormatT],
        BetaThinkingBlock,
        BetaRedactedThinkingBlock,
        BetaToolUseBlock,
        BetaServerToolUseBlock,
        BetaWebSearchToolResultBlock,
        BetaCodeExecutionToolResultBlock,
        BetaBashCodeExecutionToolResultBlock,
        BetaTextEditorCodeExecutionToolResultBlock,
        BetaMCPToolUseBlock,
        BetaMCPToolResultBlock,
        BetaContainerUploadBlock,
        BetaCompactionBlock,
    ],
    PropertyInfo(discriminator="type"),
]


class ParsedBetaMessage(BetaMessage, Generic[ResponseFormatT]):
    if TYPE_CHECKING:
        content: List[ParsedBetaContentBlock[ResponseFormatT]]  # type: ignore[assignment]
    else:
        content: List[ParsedBetaContentBlock]

    @property
    def parsed_output(self) -> Optional[ResponseFormatT]:
        for content in self.content:
            if content.type == "text" and content.parsed_output:
                return content.parsed_output
        return None

Subdomains

Frequently Asked Questions

What does parsed_beta_message.py do?
parsed_beta_message.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, AsyncAPI subdomain.
What does parsed_beta_message.py depend on?
parsed_beta_message.py imports 31 module(s): BetaBashCodeExecutionToolResultBlock, BetaCodeExecutionToolResultBlock, BetaCompactionBlock, BetaContainerUploadBlock, BetaMCPToolResultBlock, BetaMCPToolUseBlock, BetaMessage, BetaRedactedThinkingBlock, and 23 more.
What files import parsed_beta_message.py?
parsed_beta_message.py is imported by 1 file(s): message_create_params.py.
Where is parsed_beta_message.py in the architecture?
parsed_beta_message.py is located at src/anthropic/types/beta/parsed_beta_message.py (domain: AnthropicClient, subdomain: AsyncAPI, directory: src/anthropic/types/beta).

Analyze Your Own Codebase

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

Try Supermodel Free