Home / Function/ test_args_schema_as_pydantic() — langchain Function Reference

test_args_schema_as_pydantic() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8b119e08_dd0d_598f_c2e1_5d4342ec8eda["test_args_schema_as_pydantic()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  8b119e08_dd0d_598f_c2e1_5d4342ec8eda -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  beffa773_a4d3_0857_9757_4deff441ad96["_get_tool_call_json_schema()"]
  8b119e08_dd0d_598f_c2e1_5d4342ec8eda -->|calls| beffa773_a4d3_0857_9757_4deff441ad96
  style 8b119e08_dd0d_598f_c2e1_5d4342ec8eda fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 1952–1998

def test_args_schema_as_pydantic(pydantic_model: Any) -> None:
    class SomeTool(BaseTool):
        args_schema: type[pydantic_model] = pydantic_model

        @override
        def _run(self, *args: Any, **kwargs: Any) -> str:
            return "foo"

    tool = SomeTool(
        name="some_tool", description="some description", args_schema=pydantic_model
    )

    assert tool.args == {
        "a": {"title": "A", "type": "integer"},
        "b": {"title": "B", "type": "string"},
    }

    input_schema = tool.get_input_schema()
    if issubclass(input_schema, BaseModel):
        input_json_schema = input_schema.model_json_schema()
    elif issubclass(input_schema, BaseModelV1):
        input_json_schema = input_schema.schema()
    else:
        msg = "Unknown input schema type"
        raise TypeError(msg)

    assert input_json_schema == {
        "properties": {
            "a": {"title": "A", "type": "integer"},
            "b": {"title": "B", "type": "string"},
        },
        "required": ["a", "b"],
        "title": pydantic_model.__name__,
        "type": "object",
    }

    tool_json_schema = _get_tool_call_json_schema(tool)
    assert tool_json_schema == {
        "description": "some description",
        "properties": {
            "a": {"title": "A", "type": "integer"},
            "b": {"title": "B", "type": "string"},
        },
        "required": ["a", "b"],
        "title": "some_tool",
        "type": "object",
    }

Domain

Subdomains

Frequently Asked Questions

What does test_args_schema_as_pydantic() do?
test_args_schema_as_pydantic() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_args_schema_as_pydantic() defined?
test_args_schema_as_pydantic() is defined in libs/core/tests/unit_tests/test_tools.py at line 1952.
What does test_args_schema_as_pydantic() call?
test_args_schema_as_pydantic() calls 1 function(s): _get_tool_call_json_schema.

Analyze Your Own Codebase

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

Try Supermodel Free