SimpleTool

abstract class SimpleTool<TArgs> : Tool<TArgs, String> (source)

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

Parameters

TArgs

The type of arguments the tool accepts.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

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
abstract val description: String

Describes the functionality and purpose of 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
open val name: String

The name of the tool.

Link copied to clipboard
open override val resultSerializer: KSerializer<String>

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

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
abstract suspend fun doExecute(args: TArgs): String

Executes the tool's main functionality using the provided arguments and produces a textual result.

Link copied to clipboard

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

Deprecated in favor of String.

open override fun encodeResultToString(result: String): 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.