Class FunctionToolsLoader

java.lang.Object
org.machanism.machai.ai.tools.FunctionToolsLoader

public class FunctionToolsLoader extends Object
Discovers and applies FunctionTools implementations using ServiceLoader.

This class is the host-side entry point for registering a curated set of local capabilities (for example, file access, command execution, and HTTP retrieval) with a Genai. Implementations are discovered from the classpath (typically via META-INF/services provider configuration) and then applied to the provider in discovery order.

Usage


 Configurator conf = ...;
 Genai provider = ...;
 FunctionToolsLoader loader = FunctionToolsLoader.getInstance();
 loader.setConfiguration(conf);
 loader.applyTools(provider);
 
 
Author:
Viktor Tovstyi
  • Method Details

    • getInstance

      public static FunctionToolsLoader getInstance()
      Returns the singleton instance.
      Returns:
      singleton loader
    • applyTools

      public void applyTools(Genai provider)
      Applies all discovered tool installers to the given provider.
      Parameters:
      provider - provider instance to augment with tool functions
    • setConfiguration

      public void setConfiguration(Configurator configurator)
      Supplies configuration to all discovered tool installers.

      Not all FunctionTools implementations use configuration, but the loader provides a centralized way to propagate a Configurator to all tool installers (for example, for resolving header placeholders in web requests).

      Parameters:
      configurator - configuration source used by tool installers