Home / Function/ test__construct_responses_api_input_multiple_message_components() — langchain Function Reference

test__construct_responses_api_input_multiple_message_components() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  fdae8d2a_9491_f951_b231_d8757ca19f03["test__construct_responses_api_input_multiple_message_components()"]
  48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"]
  fdae8d2a_9491_f951_b231_d8757ca19f03 -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5
  style fdae8d2a_9491_f951_b231_d8757ca19f03 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 2079–2132

def test__construct_responses_api_input_multiple_message_components() -> None:
    """Test that human messages with text blocks are properly converted."""
    # v0
    messages = [
        AIMessage(
            content=[{"type": "text", "text": "foo"}, {"type": "text", "text": "bar"}],
            id="msg_123",
            response_metadata={"id": "resp_123"},
        )
    ]
    result = _construct_responses_api_input(messages)
    assert result == [
        {
            "type": "message",
            "role": "assistant",
            "content": [
                {"type": "output_text", "text": "foo", "annotations": []},
                {"type": "output_text", "text": "bar", "annotations": []},
            ],
            "id": "msg_123",
        }
    ]

    # responses/v1
    messages = [
        AIMessage(
            content=[
                {"type": "text", "text": "foo", "id": "msg_123"},
                {"type": "text", "text": "bar", "id": "msg_123"},
                {"type": "refusal", "refusal": "I refuse.", "id": "msg_123"},
                {"type": "text", "text": "baz", "id": "msg_234"},
            ]
        )
    ]
    result = _construct_responses_api_input(messages)

    assert result == [
        {
            "type": "message",
            "role": "assistant",
            "content": [
                {"type": "output_text", "text": "foo", "annotations": []},
                {"type": "output_text", "text": "bar", "annotations": []},
                {"type": "refusal", "refusal": "I refuse."},
            ],
            "id": "msg_123",
        },
        {
            "type": "message",
            "role": "assistant",
            "content": [{"type": "output_text", "text": "baz", "annotations": []}],
            "id": "msg_234",
        },
    ]

Domain

Subdomains

Frequently Asked Questions

What does test__construct_responses_api_input_multiple_message_components() do?
test__construct_responses_api_input_multiple_message_components() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is test__construct_responses_api_input_multiple_message_components() defined?
test__construct_responses_api_input_multiple_message_components() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 2079.

Analyze Your Own Codebase

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

Try Supermodel Free