SimpleTool

Represents a simplified tool base class that processes specific arguments and produces a textual result.

Parameters

TArgs

The type of arguments the tool accepts, which must be a subtype of Tool.Args.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
abstract val argsSerializer: KSerializer<TArgs>

Serializer responsible for encoding and decoding the arguments required for the tool execution. This abstract property is used to define the specific KSerializer corresponding to the type of arguments expected by the tool.

Link copied to clipboard

Provides a descriptor detailing the tool's metadata, including its name, description, and parameter requirements. This property defines the structure and characteristics of the tool, offering an overview of its functionality and how it should be used.

Link copied to clipboard

Represents the name property of the tool, derived from the tool's descriptor. This property provides an immutable reference to the tool's unique name, which is used for identification within tool registries.

Functions

Link copied to clipboard
fun decodeArgs(rawArgs: JsonObject): TArgs

Decodes the provided raw JSON arguments into an instance of the specified arguments type.

Link copied to clipboard

Decodes a raw string representation of arguments into the corresponding object of type TArgs.

Link copied to clipboard
abstract suspend fun doExecute(args: TArgs): String
Link copied to clipboard
fun encodeArgs(args: TArgs): JsonObject

Encodes the given arguments into a JSON representation.

Link copied to clipboard

Encodes the provided arguments into a JSON string representation using the configured serializer.

Link copied to clipboard
open override fun encodeResultToString(result: ToolResult.Text): String

Encodes the given result of type TResult to its string representation for the LLM.s

Link copied to clipboard

Encodes the provided result object into a JSON string representation without type safety checks.