Home / Function/ test_tool_usage() — langchain Function Reference

test_tool_usage() — langchain Function Reference

Architecture documentation for the test_tool_usage() function in test_xml.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  98f56892_4cea_6f4e_2df5_83b081018ab3["test_tool_usage()"]
  972f46cf_6d67_3d50_b55a_eec185ef4348["test_xml.py"]
  98f56892_4cea_6f4e_2df5_83b081018ab3 -->|defined in| 972f46cf_6d67_3d50_b55a_eec185ef4348
  style 98f56892_4cea_6f4e_2df5_83b081018ab3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/agents/output_parsers/test_xml.py lines 6–18

def test_tool_usage() -> None:
    parser = XMLAgentOutputParser()
    # Test when final closing </tool_input> is included
    _input = """<tool>search</tool><tool_input>foo</tool_input>"""
    output = parser.invoke(_input)
    expected_output = AgentAction(tool="search", tool_input="foo", log=_input)
    assert output == expected_output
    # Test when final closing </tool_input> is NOT included
    # This happens when it's used as a stop token
    _input = """<tool>search</tool><tool_input>foo</tool_input>"""
    output = parser.invoke(_input)
    expected_output = AgentAction(tool="search", tool_input="foo", log=_input)
    assert output == expected_output

Domain

Subdomains

Frequently Asked Questions

What does test_tool_usage() do?
test_tool_usage() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/agents/output_parsers/test_xml.py.
Where is test_tool_usage() defined?
test_tool_usage() is defined in libs/langchain/tests/unit_tests/agents/output_parsers/test_xml.py at line 6.

Analyze Your Own Codebase

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

Try Supermodel Free