Class BindexFunctionTools

java.lang.Object
org.machanism.machai.bindex.ai.tools.BindexFunctionTools
All Implemented Interfaces:
FunctionTools

public class BindexFunctionTools extends Object implements FunctionTools
An AI tool set implementation of FunctionTools that provides discovery, resolution, and registration actions for Bindex components to large language models (LLMs).

This class exposes a suite of annotated capabilities with Tool and Param metadata, enabling AI agents to seamlessly interact with Bindex repositories. Key capabilities include:

  • Discovery & Recommendation: Finding relevant libraries based on natural language project descriptions.
  • Metadata Extraction: Querying comprehensive library descriptions and schemas via specific IDs.
  • Descriptor Registration: Adding or updating library declarations from direct JSON objects, local project files, or remote URLs.
See Also:
  • Field Details

    • MODEL_PROP_NAME

      public static final String MODEL_PROP_NAME
      Property name for specifying the model to use in configuration.
      See Also:
  • Constructor Details

    • BindexFunctionTools

      public BindexFunctionTools()
      Creates a new Bindex function tool set.
  • Method Details

    • getBindex

      public org.machanism.machai.schema.Bindex getBindex(String id, String query, Configurator configurator) throws IOException
      Retrieves bindex metadata for a given project or library.

      The identifier can be either a standard Bindex ID coordinates string or a remote URL pointing directly to a Bindex JSON descriptor file.

      If a GraphQL query is provided via the graphql_query parameter, the resulting Bindex object's JSON representation will be filtered to include only the requested fields before being returned.

      Parameters:
      id - The unique Bindex identifier (e.g., 'groupId:artifactId:version') or a remote HTTP/HTTPS URL location pointing to a Bindex JSON file; must not be null.
      query - An optional GraphQL-style query to filter the response payload fields and minimize token consumption (e.g., "{ name version classification { languages } }").
      configurator - The configuration object.
      Returns:
      The filtered or complete Bindex object if found.
      Throws:
      IOException - If the remote descriptor cannot be read or serialized.
      IllegalArgumentException - If the bindex cannot be found, or if reading from the provided URL fails.
    • getRecommendedLibraries

      public Collection<BindexInfo> getRecommendedLibraries(String prompt, Double score, int vectorSearchLimits, Configurator configurator) throws IOException
      Recommends libraries based on the user's prompt or project requirements.
      Parameters:
      prompt - A description of your project needs or requirements. For example, specify the functionality, technology stack, or features you want to implement.
      score - The minimum relevance score threshold for recommended libraries. Only libraries with a score equal to or higher than this value will be included. If not specified, a default value is used.
      vectorSearchLimits - The maximum number of recommendations to retrieve from vector search.
      configurator - The configuration object.
      Returns:
      A collection of BindexInfo objects representing recommended libraries.
      Throws:
      IOException - If there is an error during recommendation.
    • registerBindex

      public String registerBindex(String path, File projectDir, Configurator configurator) throws IOException
      Registers a Bindex record from a file in the project directory.
      Parameters:
      path - The path of the Bindex file to register (must exist in the project directory). Default: "bindex.json".
      projectDir - The project directory.
      configurator - The configuration object.
      Returns:
      A map containing the record ID if registration is successful, or an error message if the file is not found.
      Throws:
      FileNotFoundException - If the specified file does not exist.
      IOException - If there is an error reading the file.
    • registerBindexJson

      public Map<String,String> registerBindexJson(org.machanism.machai.schema.Bindex bindex, Configurator configurator)
      Registers a Bindex record from a JSON object.
      Parameters:
      bindex - The Bindex JSON object.
      configurator - The configuration object.
      Returns:
      A map containing the record ID after successful registration.