test_get_last_messages_with_mixed_response_metadata() — langchain Function Reference
Architecture documentation for the test_get_last_messages_with_mixed_response_metadata() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b72847bb_f6fb_f6de_6e8f_35411a7cc073["test_get_last_messages_with_mixed_response_metadata()"] 48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"] b72847bb_f6fb_f6de_6e8f_35411a7cc073 -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5 style b72847bb_f6fb_f6de_6e8f_35411a7cc073 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 2834–2867
def test_get_last_messages_with_mixed_response_metadata() -> None:
"""Test that _get_last_messages correctly skips AIMessages without response_id."""
# Test case where the most recent AIMessage has no response_id,
# but an earlier AIMessage does have one
messages = [
HumanMessage("Hello"),
AIMessage("Hi there!", response_metadata={"id": "resp_123"}),
HumanMessage("How are you?"),
AIMessage("I'm good"), # No response_metadata
HumanMessage("What's up?"),
]
last_messages, previous_response_id = _get_last_messages(messages)
# Should return messages after the AIMessage
# with response_id (not the most recent one)
assert last_messages == [
HumanMessage("How are you?"),
AIMessage("I'm good"),
HumanMessage("What's up?"),
]
assert previous_response_id == "resp_123"
# Test case where no AIMessage has response_id
messages = [
HumanMessage("Hello"),
AIMessage("Hi there!"), # No response_metadata
HumanMessage("How are you?"),
AIMessage("I'm good"), # No response_metadata
HumanMessage("What's up?"),
]
last_messages, previous_response_id = _get_last_messages(messages)
# Should return all messages when no AIMessage has response_id
assert last_messages == messages
assert previous_response_id is None
Domain
Subdomains
Source
Frequently Asked Questions
What does test_get_last_messages_with_mixed_response_metadata() do?
test_get_last_messages_with_mixed_response_metadata() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is test_get_last_messages_with_mixed_response_metadata() defined?
test_get_last_messages_with_mixed_response_metadata() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 2834.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free