ToolFromCallable

class ToolFromCallable(callable: KCallable<*>, thisRef: Any? = null, val descriptor: ToolDescriptor, json: Json = Json, val resultSerializer: KSerializer<Any?>) : Tool<ToolFromCallable.VarArgs, Any?> (source)

A tool implementation that wraps a Kotlin callable (function, method, etc.).

See also

Constructors

Link copied to clipboard
constructor(callable: KCallable<*>, thisRef: Any? = null, descriptor: ToolDescriptor, json: Json = Json, resultSerializer: KSerializer<Any?>)

Types

Link copied to clipboard
data class VarArgs(val args: Map<KParameter, Any?>)

Represents a data structure to hold arguments conforming to the Args interface.

Link copied to clipboard

A serializer for the VarArgs class, enabling Kotlin serialization for arguments provided dynamically to a callable function (KCallable). This serializer facilitates encoding and decoding of arguments via their corresponding KParameter mappings.

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

Describes the functionality and purpose of the tool.

Link copied to clipboard
open override val descriptor: ToolDescriptor

Metadata about the tool including its name, description, and parameters.

Link copied to clipboard
open override val name: String

The name of the tool.

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

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

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

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