SafeToolFromCallable

data class SafeToolFromCallable<TResult>(val toolFunction: KFunction<TResult>, environment: AIAgentEnvironment)(source)

A wrapper class that creates a safer abstraction for executing a tool function alongside an associated environment. The tool function is backed by a callable in the form of a KFunction and interacts with the AIAgentEnvironment to perform operations and exchange data.

Parameters

TResult

The type of the result produced by the tool function.

Constructors

Link copied to clipboard
constructor(toolFunction: KFunction<TResult>, environment: AIAgentEnvironment)

Types

Link copied to clipboard
sealed interface Result<TResult>

Represents the outcome of an operation, encapsulating the result state and its associated content.

Properties

Link copied to clipboard

The Kotlin function to be wrapped and executed.

Functions

Link copied to clipboard
suspend fun execute(vararg args: Any?): SafeToolFromCallable.Result<TResult>

Executes the tool call using the provided arguments and returns the result.

Link copied to clipboard
suspend fun executeRaw(vararg args: Any?): String

Executes a raw call to the specified tool with the provided arguments and returns the result as a string.