Home / Function/ test_tool_injected_arg() — langchain Function Reference

test_tool_injected_arg() — langchain Function Reference

Architecture documentation for the test_tool_injected_arg() function in test_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6ed38263_10f1_1994_6d9c_ca4b569394da["test_tool_injected_arg()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  6ed38263_10f1_1994_6d9c_ca4b569394da -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  style 6ed38263_10f1_1994_6d9c_ca4b569394da fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 1782–1824

def test_tool_injected_arg() -> None:
    tool_ = injected_tool
    assert _schema(tool_.get_input_schema()) == {
        "title": "foo",
        "description": "Foo.",
        "type": "object",
        "properties": {
            "x": {"description": "abc", "title": "X", "type": "integer"},
            "y": {"description": "123", "title": "Y", "type": "string"},
        },
        "required": ["x", "y"],
    }
    assert _schema(tool_.tool_call_schema) == {
        "title": "foo",
        "description": "Foo.",
        "type": "object",
        "properties": {"x": {"description": "abc", "title": "X", "type": "integer"}},
        "required": ["x"],
    }
    assert tool_.invoke({"x": 5, "y": "bar"}) == "bar"
    assert tool_.invoke(
        {
            "name": "foo",
            "args": {"x": 5, "y": "bar"},
            "id": "123",
            "type": "tool_call",
        }
    ) == ToolMessage("bar", tool_call_id="123", name="foo")
    expected_error = (
        ValidationError if not isinstance(tool_, InjectedTool) else TypeError
    )
    with pytest.raises(expected_error):
        tool_.invoke({"x": 5})

    assert convert_to_openai_function(tool_) == {
        "name": "foo",
        "description": "Foo.",
        "parameters": {
            "type": "object",
            "properties": {"x": {"type": "integer", "description": "abc"}},
            "required": ["x"],
        },
    }

Domain

Subdomains

Frequently Asked Questions

What does test_tool_injected_arg() do?
test_tool_injected_arg() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_tool_injected_arg() defined?
test_tool_injected_arg() is defined in libs/core/tests/unit_tests/test_tools.py at line 1782.

Analyze Your Own Codebase

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

Try Supermodel Free