test__merge_messages() — langchain Function Reference
Architecture documentation for the test__merge_messages() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 7aba916a_ea05_b3b0_40b4_9d3063ec3fb9["test__merge_messages()"] 18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"] 7aba916a_ea05_b3b0_40b4_9d3063ec3fb9 -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311 style 7aba916a_ea05_b3b0_40b4_9d3063ec3fb9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 255–393
def test__merge_messages() -> None:
messages = [
SystemMessage("foo"), # type: ignore[misc]
HumanMessage("bar"), # type: ignore[misc]
AIMessage( # type: ignore[misc]
[
{"text": "baz", "type": "text"},
{
"tool_input": {"a": "b"},
"type": "tool_use",
"id": "1",
"text": None,
"name": "buz",
},
{"text": "baz", "type": "text"},
{
"tool_input": {"a": "c"},
"type": "tool_use",
"id": "2",
"text": None,
"name": "blah",
},
{
"tool_input": {"a": "c"},
"type": "tool_use",
"id": "3",
"text": None,
"name": "blah",
},
],
),
ToolMessage("buz output", tool_call_id="1", status="error"), # type: ignore[misc]
ToolMessage(
content=[
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "fake_image_data",
},
},
],
tool_call_id="2",
), # type: ignore[misc]
ToolMessage([], tool_call_id="3"), # type: ignore[misc]
HumanMessage("next thing"), # type: ignore[misc]
]
expected = [
SystemMessage("foo"), # type: ignore[misc]
HumanMessage("bar"), # type: ignore[misc]
AIMessage( # type: ignore[misc]
[
{"text": "baz", "type": "text"},
{
"tool_input": {"a": "b"},
"type": "tool_use",
"id": "1",
"text": None,
"name": "buz",
},
{"text": "baz", "type": "text"},
{
"tool_input": {"a": "c"},
"type": "tool_use",
"id": "2",
"text": None,
"name": "blah",
},
{
"tool_input": {"a": "c"},
"type": "tool_use",
"id": "3",
"text": None,
"name": "blah",
},
],
),
HumanMessage( # type: ignore[misc]
[
{
Domain
Subdomains
Source
Frequently Asked Questions
What does test__merge_messages() do?
test__merge_messages() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test__merge_messages() defined?
test__merge_messages() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 255.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free