Package com.rpl.agentorama
Interface ToolInfo
public interface ToolInfo
Combines a tool specification with its implementation function.
ToolInfo is used to define tools that can be called by AI models in tools agents
created with
AgentTopology.newToolsAgent(String, java.util.List). It combines
a LangChain4j ToolSpecification (which defines the tool's interface) with a function
that implements the tool's behavior.
Example:
ToolSpecification spec = ToolSpecification.builder()
.name("calculator")
.description("Performs basic arithmetic operations")
.parameters(jsonSchema)
.build();
ToolInfo toolInfo = ToolInfo.create(spec, (Map args) -> {
int a = (Integer) args.get("a");
int b = (Integer) args.get("b");
return String.valueOf(a + b);
});
// Use with newToolsAgent
topology.newToolsAgent("my-tools-agent", Arrays.asList(toolInfo));
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T1> ToolInfocreate(dev.langchain4j.agent.tool.ToolSpecification spec, com.rpl.rama.ops.RamaFunction1<Map<String, T1>, String> toolFn) Creates a tool info with a simple function implementation.static <T1,T2> ToolInfo createWithContext(dev.langchain4j.agent.tool.ToolSpecification spec, com.rpl.rama.ops.RamaFunction3<AgentNode, T1, Map<String, T2>, String> toolFn) Creates a tool info with a function that has access to the agent node context.dev.langchain4j.agent.tool.ToolSpecificationGets the tool specification for this tool.
-
Method Details
-
create
static <T1> ToolInfo create(dev.langchain4j.agent.tool.ToolSpecification spec, com.rpl.rama.ops.RamaFunction1<Map<String, T1>, String> toolFn) Creates a tool info with a simple function implementation.- Type Parameters:
T1- the type of the tool function's input- Parameters:
spec- the tool specification defining the tool's interfacetoolFn- the function that implements the tool's behavior- Returns:
- the tool info instance
-
createWithContext
static <T1,T2> ToolInfo createWithContext(dev.langchain4j.agent.tool.ToolSpecification spec, com.rpl.rama.ops.RamaFunction3<AgentNode, T1, Map<String, T2>, String> toolFn) Creates a tool info with a function that has access to the agent node context. This allows the tool function to access agent objects, stores, and other agent execution context.- Type Parameters:
T1- the type of the tool function's first inputT2- the type of the tool function's second input- Parameters:
spec- the tool specification defining the tool's interfacetoolFn- the function that implements the tool's behavior with agent context- Returns:
- the tool info instance
-
getToolSpecification
dev.langchain4j.agent.tool.ToolSpecification getToolSpecification()Gets the tool specification for this tool.- Returns:
- the tool specification
-