JTool

org.llm4s.javaapi.JTool
See theJTool companion object
final class JTool

An agent tool defined from Java (#1484), for Llm4s.createAgentWithTools. Build one from a lambda with JTool.builder, or from the Tool-annotated methods of an object with JTool.fromAnnotated:

LlmResult<JTool> weather = JTool.builder("weather", "The current weather in a city")
   .param("city", String.class, "City name")
   .handler(args -> "Sunny in " + args.getString("city"))
   .build();
LlmResult<List<JTool>> annotated = JTool.fromAnnotated(new WeatherTools());

A parameter is a String, an int, long, short or byte (boxed or not), a double or float, a boolean, or an enum (the model passes a constant's name); its JSON Schema is derived from the type. The model's arguments are read into those Java values before the handler runs, without a JSON library: a missing required argument, or one of the wrong type, is a tool error the model sees, and the handler is not called. So is an exception the handler throws - the agent keeps running.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def description(): String

What the tool does.

What the tool does.

Attributes

def name(): String

The tool's name, as the model calls it.

The tool's name, as the model calls it.

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any