Class BindexFunctionTools
- All Implemented Interfaces:
FunctionTools
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringDefault file name for the Bindex JSON metadata file.private static final StringURL to the official Bindex JSON schema definition.private BindexRepositoryRepository instance for accessing and managing Bindex records.private static final StringThe default similarity score threshold used to filter out low-confidence search results during vector search queries.static final StringProperty name for specifying the model to use in configuration.private static final StringDefault limit for the number of results returned by vector search operations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPrompt Template that loads and returns the system instructions and prompts required for Bindex generation.org.machanism.machai.schema.BindexgetBindex(String id, String query, File projectDir, Configurator configurator) Functional AI Tool that retrieves Bindex metadata for a given project or library.private BindexRepositorygetBindexRepository(Configurator configurator) Returns the currentBindexRepositoryinstance, initializing it if necessary.getBindexSchema(URI uri) Contextual Resource that retrieves the JSON Schema definition for Bindex (bundle index) validation.getRecommendedLibraries(String prompt, double score, int vectorSearchLimits, Configurator configurator) Functional AI Tool that recommends libraries based on the user's prompt or project requirements.registerBindex(String path, File projectDir, Configurator configurator) Functional AI Tool that registers a Bindex record from a file in the project directory or from a remote URL.registerBindexJson(org.machanism.machai.schema.Bindex bindex, Configurator configurator) Functional AI Tool that registers a Bindex record from a JSON object.
-
Field Details
-
BINDEX_SCHEMA
URL to the official Bindex JSON schema definition. Used for validating Bindex files and ensuring schema compliance.- See Also:
-
VECTOR_SEARCH_LIMITS
Default limit for the number of results returned by vector search operations.- See Also:
-
DEFAULT_SCORE_VALUE
The default similarity score threshold used to filter out low-confidence search results during vector search queries. Only results with a cosine similarity score greater than or equal to this value will be returned.Range: [0.0, 1.0] where 1.0 is an exact semantic match. Default:
0.85- See Also:
-
BINDEX_JSON_FILE_NAME
Default file name for the Bindex JSON metadata file.- See Also:
-
MODEL_PROP_NAME
Property name for specifying the model to use in configuration.- See Also:
-
bindexRepository
Repository instance for accessing and managing Bindex records.
-
-
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, File projectDir, Configurator configurator) throws IOException Functional AI Tool that 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_queryparameter, the resultingBindexobject'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 benull.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
Bindexobject 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.
-
getBindexRepository
Returns the currentBindexRepositoryinstance, initializing it if necessary.If the repository has not yet been created, this method instantiates a new
MongoBindexRepositoryusing a defaultPropertiesConfigurator. The same instance is returned on subsequent calls.- Parameters:
configurator- the configuration object (currently unused in this method)- Returns:
- the
BindexRepositoryinstance
-
getRecommendedLibraries
public Collection<BindexInfo> getRecommendedLibraries(String prompt, double score, int vectorSearchLimits, Configurator configurator) throws IOException Functional AI Tool that 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. The value is passed to the configured picker as the result limit.configurator- The configuration object.- Returns:
- A collection of
BindexInfoobjects representing recommended libraries. - Throws:
IOException- If there is an error during recommendation.
-
registerBindex
public String registerBindex(String path, File projectDir, Configurator configurator) throws IOException Functional AI Tool that registers a Bindex record from a file in the project directory or from a remote URL.- 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:
- The unique record ID assigned by the configured picker.
- Throws:
FileNotFoundException- If the specified file does not exist.IOException- If there is an error reading the file.
-
registerBindexJson
public String registerBindexJson(org.machanism.machai.schema.Bindex bindex, Configurator configurator) Functional AI Tool that registers a Bindex record from a JSON object.- Parameters:
bindex- The Bindex JSON object.configurator- The configuration object.- Returns:
- The unique Bindex ID assigned to the registered entry.
-
getBindexSchema
Contextual Resource that retrieves the JSON Schema definition for Bindex (bundle index) validation.This method loads the schema resource located at
/schema/bindex-schema-v2.jsonfrom the classpath and returns its content as a UTF-8 encoded string.- Parameters:
uri- the resource URI supplied by the tool framework; its path is used to locate the schema on the classpath- Returns:
- the JSON Schema content for Bindex v2
- Throws:
IOException- if the schema resource cannot be found or read
-
bindexGenerationPrompts
Prompt Template that loads and returns the system instructions and prompts required for Bindex generation.This method reads the prompt template from the classpath resource
/prompts/bindex-generation.mdand returns it as a UTF-8 encoded string.- Returns:
- the content of the Bindex generation prompt template
- Throws:
IOException- if the prompt template resource cannot be found or read
-