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 the provider's working directory context and configuration.
The apply(JsonNode, File, Configurator) method is the entry point for tool execution,
accepting provider-specific parameters, the working directory, and configuration,
and 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
Modifier and TypeMethodDescriptionapply(com.fasterxml.jackson.databind.JsonNode params, File projectDir, Configurator config) Executes the tool with the given parameters, working directory, and configuration.
-
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, File projectDir, Configurator config) throws IOException Executes the tool with the given parameters, working directory, and configuration.- Parameters:
params- provider-specific parameters, typically parsed from a JSON structureprojectDir- provider working directory context; may benullif not applicableconfig- provider configuration object, used for tool setup and execution- Returns:
- tool result (provider-specific; commonly serialized to JSON)
- Throws:
IOException- if tool execution fails due to I/O or processing errors
-