add reasoning guard; make mime type not required alongside base64

This commit is contained in:
Mason Daugherty 2025-08-04 15:52:06 -04:00
parent 7bc4512ab7
commit 5b7df921df
No known key found for this signature in database

View File

@ -949,6 +949,11 @@ def is_text_block(block: ContentBlock) -> TypeGuard[TextContentBlock]:
return block.get("type") == "text"
def is_reasoning_block(block: ContentBlock) -> TypeGuard[ReasoningContentBlock]:
"""Type guard to check if a content block is a reasoning block."""
return block.get("type") == "reasoning"
def is_invalid_tool_call_block(
block: ContentBlock,
) -> TypeGuard[InvalidToolCall]:
@ -1097,10 +1102,6 @@ def create_image_block(
msg = "Must provide one of: url, base64, or file_id"
raise ValueError(msg)
if base64 and not mime_type:
msg = "mime_type is required when using base64 data"
raise ValueError(msg)
block = ImageContentBlock(type="image", id=_ensure_id(id))
if url is not None: