ToolFunction
org.llm4s.toolapi.ToolFunction
case class ToolFunction[T, R](name: String, description: String, schema: SchemaDefinition[T], handler: SafeParameterExtractor => Either[String, R])(implicit evidence$1: ReadWriter[R])
A fully-defined, executable tool that can be invoked by an LLM.
Bundles together a name, a natural-language description (shown to the model), a SchemaDefinition that describes the expected JSON parameters, and a handler function that performs the actual work.
Prefer constructing instances via ToolBuilder rather than directly.
Type parameters
- R
-
Return type, must have a uPickle
ReadWriter - T
-
Phantom type for the parameter schema (unused at runtime)
Value parameters
- description
-
Natural-language description of what the tool does and when to use it
- handler
-
Business logic; receives a SafeParameterExtractor and returns
Right(result)orLeft(errorMessage) - name
-
Unique tool identifier used by the LLM when calling the tool
- schema
-
Parameter schema describing the expected JSON arguments
Attributes
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any
Members list
In this article