test_typed_init() — langchain Function Reference
Architecture documentation for the test_typed_init() function in test_messages.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 41c9978f_004c_bb0c_d048_3f0d7cf77c57["test_typed_init()"] 3f9e7dd9_29c9_13fc_d3d8_a14d452f0d26["test_messages.py"] 41c9978f_004c_bb0c_d048_3f0d7cf77c57 -->|defined in| 3f9e7dd9_29c9_13fc_d3d8_a14d452f0d26 style 41c9978f_004c_bb0c_d048_3f0d7cf77c57 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/test_messages.py lines 1277–1314
def test_typed_init() -> None:
ai_message = AIMessage(content_blocks=[{"type": "text", "text": "Hello"}])
assert ai_message.content == [{"type": "text", "text": "Hello"}]
assert ai_message.content_blocks == ai_message.content
human_message = HumanMessage(content_blocks=[{"type": "text", "text": "Hello"}])
assert human_message.content == [{"type": "text", "text": "Hello"}]
assert human_message.content_blocks == human_message.content
system_message = SystemMessage(content_blocks=[{"type": "text", "text": "Hello"}])
assert system_message.content == [{"type": "text", "text": "Hello"}]
assert system_message.content_blocks == system_message.content
tool_message = ToolMessage(
content_blocks=[{"type": "text", "text": "Hello"}],
tool_call_id="abc123",
)
assert tool_message.content == [{"type": "text", "text": "Hello"}]
assert tool_message.content_blocks == tool_message.content
for message_class in [AIMessage, HumanMessage, SystemMessage]:
message = message_class("Hello")
assert message.content == "Hello"
assert message.content_blocks == [{"type": "text", "text": "Hello"}]
message = message_class(content="Hello")
assert message.content == "Hello"
assert message.content_blocks == [{"type": "text", "text": "Hello"}]
# Test we get type errors for malformed blocks (type checker will complain if
# below type-ignores are unused).
_ = AIMessage(content_blocks=[{"type": "text", "bad": "Hello"}]) # type: ignore[list-item]
_ = HumanMessage(content_blocks=[{"type": "text", "bad": "Hello"}]) # type: ignore[list-item]
_ = SystemMessage(content_blocks=[{"type": "text", "bad": "Hello"}]) # type: ignore[list-item]
_ = ToolMessage(
content_blocks=[{"type": "text", "bad": "Hello"}], # type: ignore[list-item]
tool_call_id="abc123",
)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_typed_init() do?
test_typed_init() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_messages.py.
Where is test_typed_init() defined?
test_typed_init() is defined in libs/core/tests/unit_tests/test_messages.py at line 1277.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free