Home / Function/ test__format_tool_use_block() — langchain Function Reference

test__format_tool_use_block() — langchain Function Reference

Architecture documentation for the test__format_tool_use_block() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  63d5421b_3039_60f7_a425_8689ac9985c4["test__format_tool_use_block()"]
  18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"]
  63d5421b_3039_60f7_a425_8689ac9985c4 -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311
  style 63d5421b_3039_60f7_a425_8689ac9985c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 673–711

def test__format_tool_use_block() -> None:
    # Test we correctly format tool_use blocks when there is no corresponding tool_call.
    message = AIMessage(
        [
            {
                "type": "tool_use",
                "name": "foo_1",
                "id": "1",
                "input": {"bar_1": "baz_1"},
            },
            {
                "type": "tool_use",
                "name": "foo_2",
                "id": "2",
                "input": {},
                "partial_json": '{"bar_2": "baz_2"}',
                "index": 1,
            },
        ]
    )
    result = _format_messages([message])
    expected = {
        "role": "assistant",
        "content": [
            {
                "type": "tool_use",
                "name": "foo_1",
                "id": "1",
                "input": {"bar_1": "baz_1"},
            },
            {
                "type": "tool_use",
                "name": "foo_2",
                "id": "2",
                "input": {"bar_2": "baz_2"},
            },
        ],
    }
    assert result == (None, [expected])

Domain

Subdomains

Frequently Asked Questions

What does test__format_tool_use_block() do?
test__format_tool_use_block() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test__format_tool_use_block() defined?
test__format_tool_use_block() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 673.

Analyze Your Own Codebase

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

Try Supermodel Free