Package org.machanism.machai.ai.tools
Interface ToolFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface representing a tool callable by a provider during a run.
Implementations of this interface encapsulate the execution logic for a tool, typically invoked with structured arguments parsed from a model tool invocation request, along with variable runtime context objects (such as the target working directory and configurators).
The apply(JsonNode, Object...) method is the entry point for tool execution,
accepting provider-specific parameters as a JsonNode and an array of contextual objects,
returning a result object (commonly serialized to JSON).
The constant SESSION_ID_PARAM_NAME defines the standard parameter name for session identification.
Usage Example
ToolFunction tool = ...; JsonNode params = ...; File projectDir = ...; Configurator config = ...; Object result = tool.apply(params, projectDir, config);
- Author:
- Viktor Tovstyi
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringStandard parameter name for session identification in tool requests. -
Method Summary
-
Field Details
-
SESSION_ID_PARAM_NAME
Standard parameter name for session identification in tool requests.- See Also:
-
-
Method Details
-
apply
Object apply(com.fasterxml.jackson.databind.JsonNode params, Object... paramsByType) throws Exception Executes the tool with the given parameters and variable context instances.- Parameters:
params- provider-specific parameters, typically parsed from a JSON structureparamsByType- variable-arity parameter list representing runtime contextual environments (e.g.Filefor working directory,Configuratorfor lookups)- Returns:
- the tool execution result (commonly a string or object serializable to JSON)
- Throws:
Exception- if tool execution fails during processing
-