From 5b7df921df44fcf501e914cee84167110f3896e8 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 4 Aug 2025 15:52:06 -0400 Subject: [PATCH] add reasoning guard; make mime type not required alongside base64 --- libs/core/langchain_core/messages/content_blocks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/core/langchain_core/messages/content_blocks.py b/libs/core/langchain_core/messages/content_blocks.py index 94342bea357..abae6bc8666 100644 --- a/libs/core/langchain_core/messages/content_blocks.py +++ b/libs/core/langchain_core/messages/content_blocks.py @@ -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: