test_complex_ai_message_chunks() — langchain Function Reference
Architecture documentation for the test_complex_ai_message_chunks() function in test_messages.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ae71e210_4c58_2004_5bef_fbacf8845b2f["test_complex_ai_message_chunks()"] 1c821c4f_25a2_9606_a15f_b3df054105ac["test_messages.py"] ae71e210_4c58_2004_5bef_fbacf8845b2f -->|defined in| 1c821c4f_25a2_9606_a15f_b3df054105ac style ae71e210_4c58_2004_5bef_fbacf8845b2f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/test_messages.py lines 229–305
def test_complex_ai_message_chunks() -> None:
assert AIMessageChunk(content=["I am"], id="ai4") + AIMessageChunk(
content=[" indeed."]
) == AIMessageChunk(id="ai4", content=["I am", " indeed."]), (
"Content concatenation with arrays of strings should naively combine"
)
assert AIMessageChunk(content=[{"index": 0, "text": "I am"}]) + AIMessageChunk(
content=" indeed."
) == AIMessageChunk(content=[{"index": 0, "text": "I am"}, " indeed."]), (
"Concatenating mixed content arrays should naively combine them"
)
assert AIMessageChunk(content=[{"index": 0, "text": "I am"}]) + AIMessageChunk(
content=[{"index": 0, "text": " indeed."}]
) == AIMessageChunk(content=[{"index": 0, "text": "I am indeed."}]), (
"Concatenating when both content arrays are dicts with the same index "
"should merge"
)
assert AIMessageChunk(content=[{"index": 0, "text": "I am"}]) + AIMessageChunk(
content=[{"text": " indeed."}]
) == AIMessageChunk(content=[{"index": 0, "text": "I am"}, {"text": " indeed."}]), (
"Concatenating when one chunk is missing an index should not merge or throw"
)
assert AIMessageChunk(content=[{"index": 0, "text": "I am"}]) + AIMessageChunk(
content=[{"index": 2, "text": " indeed."}]
) == AIMessageChunk(
content=[{"index": 0, "text": "I am"}, {"index": 2, "text": " indeed."}]
), (
"Concatenating when both content arrays are dicts with a gap between indexes "
"should not result in a holey array"
)
assert AIMessageChunk(content=[{"index": 0, "text": "I am"}]) + AIMessageChunk(
content=[{"index": 1, "text": " indeed."}]
) == AIMessageChunk(
content=[{"index": 0, "text": "I am"}, {"index": 1, "text": " indeed."}]
), (
"Concatenating when both content arrays are dicts with separate indexes "
"should not merge"
)
assert AIMessageChunk(
content=[{"index": 0, "text": "I am", "type": "text_block"}]
) + AIMessageChunk(
content=[{"index": 0, "text": " indeed.", "type": "text_block"}]
) == AIMessageChunk(
content=[{"index": 0, "text": "I am indeed.", "type": "text_block"}]
), (
"Concatenating when both content arrays are dicts with the same index and type "
"should merge"
)
assert AIMessageChunk(
content=[{"index": 0, "text": "I am", "type": "text_block"}]
) + AIMessageChunk(
content=[{"index": 0, "text": " indeed.", "type": "text_block_delta"}]
) == AIMessageChunk(
content=[{"index": 0, "text": "I am indeed.", "type": "text_block"}]
), (
"Concatenating when both content arrays are dicts with the same index "
"and different types should merge without updating type"
)
assert AIMessageChunk(
content=[{"index": 0, "text": "I am", "type": "text_block"}]
) + AIMessageChunk(
content="", response_metadata={"extra": "value"}
) == AIMessageChunk(
content=[{"index": 0, "text": "I am", "type": "text_block"}],
response_metadata={"extra": "value"},
), (
"Concatenating when one content is an array and one is an empty string "
"should not add a new item, but should concat other fields"
)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_complex_ai_message_chunks() do?
test_complex_ai_message_chunks() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_messages.py.
Where is test_complex_ai_message_chunks() defined?
test_complex_ai_message_chunks() is defined in libs/core/tests/unit_tests/test_messages.py at line 229.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free