test_handle_empty_aimessage() — langchain Function Reference
Architecture documentation for the test_handle_empty_aimessage() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ed4d9cd2_9b46_c1d4_030e_1b15fbb45ccb["test_handle_empty_aimessage()"] f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"] ed4d9cd2_9b46_c1d4_030e_1b15fbb45ccb -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f style ed4d9cd2_9b46_c1d4_030e_1b15fbb45ccb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 283–327
def test_handle_empty_aimessage() -> None:
# Anthropic can generate empty AIMessages, which are not valid unless in the last
# message in a sequence.
llm = ChatAnthropic(model=MODEL_NAME)
messages = [
HumanMessage("Hello"),
AIMessage([]),
HumanMessage("My name is Bob."),
]
_ = llm.invoke(messages)
# Test tool call sequence
llm_with_tools = llm.bind_tools(
[
{
"name": "get_weather",
"description": "Get weather report for a city",
"input_schema": {
"type": "object",
"properties": {"location": {"type": "string"}},
},
},
],
)
_ = llm_with_tools.invoke(
[
HumanMessage("What's the weather in Boston?"),
AIMessage(
content=[],
tool_calls=[
{
"name": "get_weather",
"args": {"location": "Boston"},
"id": "toolu_01V6d6W32QGGSmQm4BT98EKk",
"type": "tool_call",
},
],
),
ToolMessage(
content="It's sunny.", tool_call_id="toolu_01V6d6W32QGGSmQm4BT98EKk"
),
AIMessage([]),
HumanMessage("Thanks!"),
]
)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_handle_empty_aimessage() do?
test_handle_empty_aimessage() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py.
Where is test_handle_empty_aimessage() defined?
test_handle_empty_aimessage() is defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py at line 283.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free