tools/utils/tool_support library

Functions

booleanProperty(String description) → Map<String, Object?>
defineTextTool(Genkit ai, {required ToolRuntime runtime, required String name, required String description, Map<String, Object?> properties = const <String, Object?>{}, List<String> required = const <String>[], required Future<String> run(JsonMap input)}) → Tool<JsonMap, String>
Defines a tool that takes a JSON object and returns text to the model.
integerProperty(String description) → Map<String, Object?>
objectSchema({Map<String, Object?> properties = const <String, Object?>{}, List<String> required = const <String>[]}) → SchemanticType<JsonMap>
Builds an object input schema from plain JSON Schema property maps.
parseJsonMap(Object? json) → JsonMap
readBool(JsonMap input, String key) → bool?
readInt(JsonMap input, String key) → int?
readJsonMap(JsonMap input, String key) → JsonMap?
readList(JsonMap input, String key) → List?
readString(JsonMap input, String key) → String?
requireString(JsonMap input, String key) → String
Reads a string that must be present and non-blank.
stringProperty(String description, {List<String>? enumValues}) → Map<String, Object?>
truncateMiddle(String text, int maxChars) → String
Shortens text to at most maxChars, keeping the start and the end.

Typedefs

JsonMap = Map<String, dynamic>

Exceptions / Errors

ToolFailure
A recoverable tool error that is reported back to the model as text.