Home / Function/ test_filter_message_exclude_tool_calls() — langchain Function Reference

test_filter_message_exclude_tool_calls() — langchain Function Reference

Architecture documentation for the test_filter_message_exclude_tool_calls() function in test_utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8a0226aa_ee26_2cac_f4fa_ba5e5c5543d4["test_filter_message_exclude_tool_calls()"]
  03f6a5ae_d57a_eb66_626a_b9e082b763ea["test_utils.py"]
  8a0226aa_ee26_2cac_f4fa_ba5e5c5543d4 -->|defined in| 03f6a5ae_d57a_eb66_626a_b9e082b763ea
  style 8a0226aa_ee26_2cac_f4fa_ba5e5c5543d4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/messages/test_utils.py lines 184–219

def test_filter_message_exclude_tool_calls() -> None:
    tool_calls = [
        {"name": "foo", "id": "1", "args": {}, "type": "tool_call"},
        {"name": "bar", "id": "2", "args": {}, "type": "tool_call"},
    ]
    messages = [
        HumanMessage("foo", name="blah", id="1"),
        AIMessage("foo-response", name="blah", id="2"),
        HumanMessage("bar", name="blur", id="3"),
        AIMessage(
            "bar-response",
            tool_calls=tool_calls,
            id="4",
        ),
        ToolMessage("baz", tool_call_id="1", id="5"),
        ToolMessage("qux", tool_call_id="2", id="6"),
    ]
    messages_model_copy = [m.model_copy(deep=True) for m in messages]
    expected = messages[:3]

    # test excluding all tool calls
    actual = filter_messages(messages, exclude_tool_calls=True)
    assert expected == actual

    # test explicitly excluding all tool calls
    actual = filter_messages(messages, exclude_tool_calls=["1", "2"])
    assert expected == actual

    # test excluding a specific tool call
    expected = messages[:5]
    expected[3] = expected[3].model_copy(update={"tool_calls": [tool_calls[0]]})
    actual = filter_messages(messages, exclude_tool_calls=["2"])
    assert expected == actual

    # assert that we didn't mutate the original messages
    assert messages == messages_model_copy

Domain

Subdomains

Frequently Asked Questions

What does test_filter_message_exclude_tool_calls() do?
test_filter_message_exclude_tool_calls() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/messages/test_utils.py.
Where is test_filter_message_exclude_tool_calls() defined?
test_filter_message_exclude_tool_calls() is defined in libs/core/tests/unit_tests/messages/test_utils.py at line 184.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free