Home / Function/ test_serdes_message_chunk() — langchain Function Reference

test_serdes_message_chunk() — langchain Function Reference

Architecture documentation for the test_serdes_message_chunk() function in test_ai.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  08a6e38e_0669_e774_6c98_0b96482c3365["test_serdes_message_chunk()"]
  f148f3ce_73bd_627d_a979_33d23ebac843["test_ai.py"]
  08a6e38e_0669_e774_6c98_0b96482c3365 -->|defined in| f148f3ce_73bd_627d_a979_33d23ebac843
  style 08a6e38e_0669_e774_6c98_0b96482c3365 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/messages/test_ai.py lines 53–105

def test_serdes_message_chunk() -> None:
    chunk = AIMessageChunk(
        content=[{"text": "blah", "type": "text"}],
        tool_call_chunks=[
            create_tool_call_chunk(name="foo", args='{"bar": 1}', id="baz", index=0),
            create_tool_call_chunk(
                name="foobad",
                args="blah",
                id="booz",
                index=1,
            ),
        ],
    )
    expected = {
        "lc": 1,
        "type": "constructor",
        "id": ["langchain", "schema", "messages", "AIMessageChunk"],
        "kwargs": {
            "type": "AIMessageChunk",
            "content": [{"text": "blah", "type": "text"}],
            "tool_calls": [
                {"name": "foo", "args": {"bar": 1}, "id": "baz", "type": "tool_call"}
            ],
            "invalid_tool_calls": [
                {
                    "name": "foobad",
                    "args": "blah",
                    "id": "booz",
                    "error": None,
                    "type": "invalid_tool_call",
                }
            ],
            "tool_call_chunks": [
                {
                    "name": "foo",
                    "args": '{"bar": 1}',
                    "id": "baz",
                    "index": 0,
                    "type": "tool_call_chunk",
                },
                {
                    "name": "foobad",
                    "args": "blah",
                    "id": "booz",
                    "index": 1,
                    "type": "tool_call_chunk",
                },
            ],
        },
    }
    actual = dumpd(chunk)
    assert actual == expected
    assert load(actual, allowed_objects=[AIMessageChunk]) == chunk

Domain

Subdomains

Frequently Asked Questions

What does test_serdes_message_chunk() do?
test_serdes_message_chunk() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/messages/test_ai.py.
Where is test_serdes_message_chunk() defined?
test_serdes_message_chunk() is defined in libs/core/tests/unit_tests/messages/test_ai.py at line 53.

Analyze Your Own Codebase

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

Try Supermodel Free