org.llm4s.javaapi.JTool
See theJTool companion object
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 Objecttrait Matchableclass Any
Members list
In this article