ToolsUnitTests#
- class langchain_tests.unit_tests.tools.ToolsUnitTests[source]#
Base class for tools unit tests.
Attributes
init_from_env_params
Return env vars, init args, and expected instance attrs for initializing from env vars.
tool_constructor
Returns a class or instance of a tool to be tested.
tool_constructor_params
Returns a dictionary of parameters to pass to the tool constructor.
tool_invoke_params_example
Returns a dictionary representing the "args" of an example tool call.
Methods
test_has_input_schema
(tool)Tests that the tool has an input schema.
test_has_name
(tool)Tests that the tool has a name attribute to pass to chat models.
Test that the tool can be initialized with
tool_constructor
andtool_constructor_params
.Tests that the provided example params match the declared input schema.
- test_has_input_schema(tool: BaseTool) None [source]#
Tests that the tool has an input schema.
If this fails, add an args_schema to your tool.
See this guide and see how CalculatorInput is configured in the CustomCalculatorTool.args_schema attribute
- Parameters:
tool (BaseTool)
- Return type:
None
- test_has_name(tool: BaseTool) None [source]#
Tests that the tool has a name attribute to pass to chat models.
If this fails, add a name parameter to your tool.
- Parameters:
tool (BaseTool)
- Return type:
None
- test_init() None [source]#
Test that the tool can be initialized with
tool_constructor
andtool_constructor_params
. If this fails, check that the keyword args defined intool_constructor_params
are valid.- Return type:
None
- test_input_schema_matches_invoke_params(tool: BaseTool) None [source]#
Tests that the provided example params match the declared input schema.
If this fails, update the tool_invoke_params_example attribute to match the input schema (args_schema) of the tool.
- Parameters:
tool (BaseTool)
- Return type:
None