Home / Function/ _has_base64_data() — langchain Function Reference

_has_base64_data() — langchain Function Reference

Architecture documentation for the _has_base64_data() function in utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  0cbee999_e800_48f7_a4ea_c05ff0851910["_has_base64_data()"]
  0b528c80_0ce7_1c74_8932_bc433bcb03c6["utils.py"]
  0cbee999_e800_48f7_a4ea_c05ff0851910 -->|defined in| 0b528c80_0ce7_1c74_8932_bc433bcb03c6
  8c272a75_04d0_f5f2_a5cd_cd4a21d4dfdd["_format_content_block_xml()"]
  8c272a75_04d0_f5f2_a5cd_cd4a21d4dfdd -->|calls| 0cbee999_e800_48f7_a4ea_c05ff0851910
  style 0cbee999_e800_48f7_a4ea_c05ff0851910 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/utils.py lines 104–129

def _has_base64_data(block: dict) -> bool:
    """Check if a content block contains base64 encoded data.

    Args:
        block: A content block dictionary.

    Returns:
        Whether the block contains base64 data.
    """
    # Check for explicit base64 field (standard content blocks)
    if block.get("base64"):
        return True

    # Check for data: URL in url field
    url = block.get("url", "")
    if isinstance(url, str) and url.startswith("data:"):
        return True

    # Check for OpenAI-style image_url with data: URL
    image_url = block.get("image_url", {})
    if isinstance(image_url, dict):
        url = image_url.get("url", "")
        if isinstance(url, str) and url.startswith("data:"):
            return True

    return False

Subdomains

Frequently Asked Questions

What does _has_base64_data() do?
_has_base64_data() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/utils.py.
Where is _has_base64_data() defined?
_has_base64_data() is defined in libs/core/langchain_core/messages/utils.py at line 104.
What calls _has_base64_data()?
_has_base64_data() is called by 1 function(s): _format_content_block_xml.

Analyze Your Own Codebase

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

Try Supermodel Free