Package org.machanism.machai.ai.tools
Types in this package are deliberately provider-neutral. An application
implements the marker interface FunctionTools to group capabilities
and declares those capabilities on methods with runtime-retained annotations, while a
provider-specific integration discovers the annotations, describes the
callable operations, validates arguments, and invokes the methods.
Declaring capabilities
Toolmarks a method as an invokable tool and requires a human-readable description;Tool.name()optionally supplies its exposed name.Promptmarks a method as a prompt definition and associates it with aRole; its parameters may be described withParam.Resourcemarks a method that supplies content identified by one or more URIs, such as schemas, configuration, or instruction documents.Paramsupplies runtime parameter metadata, including a name, description, and optional default value.
Provider integration
FunctionTools is the service-provider interface used to group related
capabilities. FunctionToolsLoader discovers implementations with
ServiceLoader, optionally filters them with SupportedFor,
and registers compatible implementations with a provider. ToolFunction
provides a functional abstraction for executing a tool with structured
JsonNode parameters and runtime context.
Supporting types
ParamDescriptorrepresents parameter metadata programmatically when an annotation is not sufficient.Roleidentifies the assistant and user conversation roles.ErrorResultExceptioncarries a structured, JSON-serializable tool error.SpecialExceptionsignals a framework-level special condition, such as the completion of a task without shutting down the host application.
Typical usage
public final class ProjectTools implements FunctionTools {
-
ClassDescriptionA runtime exception used to signal a tool or processing error, with a structured error payload that is serialized to JSON and included in the exception message.Service-provider interface (SPI) for installing host-provided function tools.Discovers and applies
FunctionToolsimplementations using Java'sServiceLoadermechanism.Descriptor for a parameter used in tool or prompt definitions within the AI provider framework.Annotation to mark a method as a prompt within the AI provider framework.Annotation used to declare a method as an executable resource provider within the generative-AI tools system.Enumeration representing participant roles in an AI interaction context.Exception used to signal the end of a task without terminating the application.Indicates which application classes aFunctionToolsimplementation supports.Annotation to mark a method as a tool function within the AI provider framework.Functional interface representing a tool callable by a provider during a run.