org.llm4s.toolapi.ToolBuilder
See theToolBuilder companion object
Builder for ToolFunction definitions using a fluent API.
Obtained via the companion ToolBuilder object:
ToolBuilder[Map[String, Any], MyResult]("my_tool", "Does something", schema)
.withHandler(extractor => Right(MyResult(...)))
.buildSafe()
Value parameters
-
description
-
Natural-language description for the LLM
-
handler
-
Optional handler; must be set before calling buildSafe
-
name
-
Tool name
-
schema
-
Parameter schema
Attributes
-
Companion
-
object
-
Graph
-
-
Supertypes
-
class Object
trait Matchable
class Any
Members list
Build the tool function, returning a Result for safe error handling.
Build the tool function, returning a Result for safe error handling.
Attributes
-
Returns
-
Right(ToolFunction) if handler is defined, Left(ValidationError) otherwise
Set the handler function for this tool.
Set the handler function for this tool.
Value parameters
-
handler
-
Function that extracts parameters and executes the tool's logic
Attributes
-
Returns
-
A new builder with the handler registered
Build the tool function, throwing on failure.
Build the tool function, throwing on failure.
Prefer buildSafe which returns Result[ToolFunction] and avoids throwing.
Attributes
-
Throws
-
java.lang.IllegalStateException
if handler is not defined
-
Deprecated
-
[Since version 0.2.9] Use buildSafe() which returns Result[ToolFunction] for safe error handling