Home / Function/ test_trace_content_blocks_with_no_type_key() — langchain Function Reference

test_trace_content_blocks_with_no_type_key() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  656ebeba_2708_0418_d425_7edf20757376["test_trace_content_blocks_with_no_type_key()"]
  8830054d_ac1e_daa9_c6c5_ff55b10d0bf3["test_base.py"]
  656ebeba_2708_0418_d425_7edf20757376 -->|defined in| 8830054d_ac1e_daa9_c6c5_ff55b10d0bf3
  style 656ebeba_2708_0418_d425_7edf20757376 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/language_models/chat_models/test_base.py lines 597–674

def test_trace_content_blocks_with_no_type_key(output_version: str) -> None:
    """Test behavior of content blocks that don't have a `type` key.

    Only for blocks with one key, in which case, the name of the key is used as `type`.

    """
    llm = ParrotFakeChatModel(output_version=output_version)
    messages = [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Hello",
                },
                {
                    "cachePoint": {"type": "default"},
                },
            ],
        }
    ]
    tracer = FakeChatModelStartTracer()
    response = llm.invoke(messages, config={"callbacks": [tracer]})
    assert tracer.messages == [
        [
            [
                HumanMessage(
                    [
                        {
                            "type": "text",
                            "text": "Hello",
                        },
                        {
                            "type": "cachePoint",
                            "cachePoint": {"type": "default"},
                        },
                    ]
                )
            ]
        ]
    ]

    if output_version == "v0":
        assert response.content == [
            {
                "type": "text",
                "text": "Hello",
            },
            {
                "cachePoint": {"type": "default"},
            },
        ]
    else:
        assert response.content == [
            {
                "type": "text",
                "text": "Hello",
            },
            {
                "type": "non_standard",
                "value": {
                    "cachePoint": {"type": "default"},
                },
            },
        ]

    assert response.content_blocks == [
        {
            "type": "text",
            "text": "Hello",
        },
        {
            "type": "non_standard",
            "value": {
                "cachePoint": {"type": "default"},
            },
        },
    ]

Subdomains

Frequently Asked Questions

What does test_trace_content_blocks_with_no_type_key() do?
test_trace_content_blocks_with_no_type_key() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py.
Where is test_trace_content_blocks_with_no_type_key() defined?
test_trace_content_blocks_with_no_type_key() is defined in libs/core/tests/unit_tests/language_models/chat_models/test_base.py at line 597.

Analyze Your Own Codebase

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

Try Supermodel Free