BaseTool
Base class for defining callable tools that an LLM can invoke.
Tools allow the model to interact with external systems (databases, APIs, etc.). To create a tool:
Subclass BaseTool with your args type and return type.
Define a
@Serializabledata class for your arguments.Annotate argument properties with @ToolParam to provide descriptions for the JSON schema.
Override argsSerializer and execute.
Type Parameters
The type of the tool's input arguments.
The return type of the tool's execution.
Inheritors
Constructors
Properties
The kotlinx.serialization KSerializer for the ARGS type. Used to generate the JSON schema for the tool's parameters.
A human-readable description of what the tool does.
The kotlinx.serialization KSerializer for the R type. Used to generate the JSON schema for the tool's results.
Functions
Executes the tool from raw JSON arguments.