ToolManager constructor

ToolManager({
  1. List<Tool> tools = const [],
})

Creates a tool manager with the given tools.

Implementation

ToolManager({List<Tool> tools = const []}) : _tools = {} {
  for (final tool in tools) {
    final description = tool.getToolDescription();
    final function = description['function'];
    if (function is! Map || function['name'] is! String) {
      throw const LiteRtLmException(
        'Tool description must contain ["function"]["name"].',
      );
    }
    _tools[function['name'] as String] = tool;
  }
}