Tool<Input extends Object, Options extends ToolOptions, Output extends Object> constructor

Tool<Input extends Object, Options extends ToolOptions, Output extends Object>({
  1. required String name,
  2. required String description,
  3. required Map<String, dynamic> inputJsonSchema,
  4. bool strict = false,
  5. bool returnDirect = false,
  6. Output handleToolError(
    1. ToolException
    )?,
  7. Options? defaultOptions,
})

A LangChain tool.

The Input to the tool needs to be described by the inputJsonSchema.

You can easily create a tool from a function using Tool.fromFunction.

If you want to create a tool that accepts a single string input and returns a string output, you can use StringTool or StringTool.fromFunction.

Implementation

Tool({
  required this.name,
  required this.description,
  required this.inputJsonSchema,
  this.strict = false,
  this.returnDirect = false,
  this.handleToolError,
  final Options? defaultOptions,
})  : assert(name.isNotEmpty, 'Tool name cannot be empty.'),
      assert(description.isNotEmpty, 'Tool description cannot be empty.'),
      super(defaultOptions: defaultOptions ?? const ToolOptions() as Options);