Home / Function/ test_extend_support_to_openai_multimodal_formats() — langchain Function Reference

test_extend_support_to_openai_multimodal_formats() — langchain Function Reference

Architecture documentation for the test_extend_support_to_openai_multimodal_formats() function in test_base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  df0ba3df_08c0_7a2d_0467_4cc7f613eed0["test_extend_support_to_openai_multimodal_formats()"]
  8cb88ac4_61d9_baf3_9df4_9b3f5095927e["test_base.py"]
  df0ba3df_08c0_7a2d_0467_4cc7f613eed0 -->|defined in| 8cb88ac4_61d9_baf3_9df4_9b3f5095927e
  bef134a6_e8e6_dbce_bf24_24e52ed42702["_content_blocks_equal_ignore_id()"]
  df0ba3df_08c0_7a2d_0467_4cc7f613eed0 -->|calls| bef134a6_e8e6_dbce_bf24_24e52ed42702
  style df0ba3df_08c0_7a2d_0467_4cc7f613eed0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/language_models/chat_models/test_base.py lines 677–806

def test_extend_support_to_openai_multimodal_formats() -> None:
    """Test normalizing OpenAI audio, image, and file inputs to v1."""
    # Audio and file only (chat model default)
    messages = HumanMessage(
        content=[
            {"type": "text", "text": "Hello"},
            {  # audio-base64
                "type": "input_audio",
                "input_audio": {
                    "format": "wav",
                    "data": "<base64 string>",
                },
            },
            {  # file-base64
                "type": "file",
                "file": {
                    "filename": "draconomicon.pdf",
                    "file_data": "data:application/pdf;base64,<base64 string>",
                },
            },
            {  # file-id
                "type": "file",
                "file": {"file_id": "<file id>"},
            },
        ]
    )

    expected_content_messages = HumanMessage(
        content=[
            {"type": "text", "text": "Hello"},  # TextContentBlock
            {  # AudioContentBlock
                "type": "audio",
                "base64": "<base64 string>",
                "mime_type": "audio/wav",
            },
            {  # FileContentBlock
                "type": "file",
                "base64": "<base64 string>",
                "mime_type": "application/pdf",
                "extras": {"filename": "draconomicon.pdf"},
            },
            {  # ...
                "type": "file",
                "file_id": "<file id>",
            },
        ]
    )

    normalized_content = _normalize_messages([messages])

    # Check structure, ignoring auto-generated IDs
    assert len(normalized_content) == 1
    normalized_message = normalized_content[0]
    assert len(normalized_message.content) == len(expected_content_messages.content)

    assert _content_blocks_equal_ignore_id(
        normalized_message.content, expected_content_messages.content
    )

    messages = HumanMessage(
        content=[
            {"type": "text", "text": "Hello"},
            {  # image-url
                "type": "image_url",
                "image_url": {"url": "https://example.com/image.png"},
            },
            {  # image-base64
                "type": "image_url",
                "image_url": {"url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."},
            },
            {  # audio-base64
                "type": "input_audio",
                "input_audio": {
                    "format": "wav",
                    "data": "<base64 string>",
                },
            },
            {  # file-base64
                "type": "file",
                "file": {
                    "filename": "draconomicon.pdf",

Domain

Subdomains

Frequently Asked Questions

What does test_extend_support_to_openai_multimodal_formats() do?
test_extend_support_to_openai_multimodal_formats() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py.
Where is test_extend_support_to_openai_multimodal_formats() defined?
test_extend_support_to_openai_multimodal_formats() is defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py at line 677.
What does test_extend_support_to_openai_multimodal_formats() call?
test_extend_support_to_openai_multimodal_formats() calls 1 function(s): _content_blocks_equal_ignore_id.

Analyze Your Own Codebase

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

Try Supermodel Free