StringTool<Options extends ToolOptions> class abstract base

Base class for tools that accept a single string input and returns a string output.

Inheritance
Implementers

Constructors

StringTool({required String name, required String description, String inputDescription = 'The input to the tool', bool strict = false, bool returnDirect = false, String handleToolError(ToolException)?, Options? defaultOptions})
Base class for tools that accept a single string input and returns a string output.

Properties

defaultOptions → Options
The default options to use when invoking the Runnable.
finalinherited
description String
Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description.
finalinherited
handleToolError String Function(ToolException)?
Handle the content of the ToolException thrown by the tool.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
inputJsonSchema Map<String, dynamic>
Schema to parse and validate tool's input arguments. Following the JSON Schema specification.
finalinherited
name String
The unique name of the tool that clearly communicates its purpose.
finalinherited
returnDirect bool
Whether to return the tool's output directly. Setting this to true means that after the tool is called, the AgentExecutor will stop looping.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
strict bool
Whether to enable strict schema adherence when generating the tool call. If set to true, the model will follow the exact schema defined in the inputJsonSchema field.
finalinherited

Methods

batch(List<String> inputs, {List<Options>? options}) Future<List<String>>
Batches the invocation of the Runnable on the given inputs.
inherited
bind(Options options) RunnableBinding<String, Options, String>
Binds the Runnable to the given options.
inherited
close() → void
Cleans up any resources associated with it the Runnable.
inherited
getCompatibleOptions(RunnableOptions? options) → Options?
Returns the given options if they are compatible with the Runnable, otherwise returns null.
inherited
getInputFromJson(Map<String, dynamic> json) String
Parses the input JSON to the tool's input type.
override
invoke(String input, {Options? options}) Future<String>
Runs the tool.
inherited
invokeInternal(String toolInput, {Options? options}) Future<String>
Actual implementation of invoke method logic with string input.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pipe<NewRunOutput extends Object?, NewCallOptions extends RunnableOptions>(Runnable<String, NewCallOptions, NewRunOutput> next) RunnableSequence<String, NewRunOutput>
Pipes the output of this Runnable into another Runnable using a RunnableSequence.
inherited
stream(String input, {Options? options}) Stream<String>
Streams the output of invoking the Runnable on the given input.
inherited
streamFromInputStream(Stream<String> inputStream, {Options? options}) Stream<String>
Streams the tool's output for the input resulting from reducing the input stream.
inherited
toJson() Map<String, dynamic>
Converts the tool spec to a JSON-serializable map.
inherited
toString() String
A string representation of this object.
inherited
withFallbacks(List<Runnable<String, RunnableOptions, String>> fallbacks) RunnableWithFallback<String, String>
Adds fallback runnables to be invoked if the primary runnable fails.
inherited
withRetry({int maxRetries = 3, FutureOr<bool> retryIf(Object e)?, List<Duration?>? delayDurations, bool addJitter = false}) RunnableRetry<String, String>
Adds retry logic to an existing runnable.
inherited

Operators

operator ==(covariant ToolSpec other) bool
The equality operator.
inherited

Static Methods

fromFunction<Options extends ToolOptions>({required String name, required String description, String inputDescription = 'The input to the tool', bool strict = false, required FutureOr<String> func(String input), bool returnDirect = false, String handleToolError(ToolException)?}) StringTool<ToolOptions>
Creates a StringTool from a function.
override