test_trim_messages_token_counter_shortcut_with_options() — langchain Function Reference
Architecture documentation for the test_trim_messages_token_counter_shortcut_with_options() function in test_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 53b6a430_5261_086a_daa3_a2f4af719a89["test_trim_messages_token_counter_shortcut_with_options()"] ea3f8d89_f44b_6738_3cb9_a740a73cfca4["test_utils.py"] 53b6a430_5261_086a_daa3_a2f4af719a89 -->|defined in| ea3f8d89_f44b_6738_3cb9_a740a73cfca4 style 53b6a430_5261_086a_daa3_a2f4af719a89 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/messages/test_utils.py lines 728–753
def test_trim_messages_token_counter_shortcut_with_options() -> None:
"""Test that `'approximate'` shortcut works with different trim options."""
messages = [
SystemMessage("System instructions"),
HumanMessage("First human message", id="first"),
AIMessage("First AI response", id="ai1"),
HumanMessage("Second human message", id="second"),
AIMessage("Second AI response", id="ai2"),
]
messages_copy = [m.model_copy(deep=True) for m in messages]
# Test with various options
result = trim_messages(
messages,
max_tokens=100,
token_counter="approximate",
strategy="last",
include_system=True,
start_on="human",
)
# Should include system message and start on human
assert len(result) >= 2
assert isinstance(result[0], SystemMessage)
assert any(isinstance(msg, HumanMessage) for msg in result[1:])
assert messages == messages_copy
Domain
Subdomains
Source
Frequently Asked Questions
What does test_trim_messages_token_counter_shortcut_with_options() do?
test_trim_messages_token_counter_shortcut_with_options() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/messages/test_utils.py.
Where is test_trim_messages_token_counter_shortcut_with_options() defined?
test_trim_messages_token_counter_shortcut_with_options() is defined in libs/core/tests/unit_tests/messages/test_utils.py at line 728.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free