|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIX. - Grok / X - API > !Tool and Function Management > AIX - Artificial Intelligence and X Platform Utility |
MiniRobotLanguage (MRL)
AIX.Get Tools
Retrieve the Current Tools Configuration
Intention
Get Tools Command: Inspect Available AI Tools
The Get Tools command retrieves the current configuration of tools available to the Grok AI, as previously defined using the AIX.Set Tools command. This configuration, typically represented as a JSON string, specifies the external functions or APIs the AI can invoke to enhance its responses, such as retrieving real-time data or performing calculations.
This command is essential for verifying the tools setup, ensuring the AI operates within the intended capabilities, and supporting debugging or workflow adjustments.
It’s part of the AIX - Grok / X - API suite.
The Get Tools command retrieves the current tools configuration stored in a global variable (e.g., AIX_Tools), which is set by the AIX.Set Tools command. This configuration is a JSON string that defines a list of tools, each with a name and description, and potentially additional parameters like arguments or constraints.
For example, a tools configuration might look like [{"name": "get_time", "description": "Get the current time", "args": {"format": "HH:MM"}}]. This data is used by the HTP_AnalyzeGrokResponse subroutine to interpret tool_calls in the AI’s responses, enabling the AI to invoke these tools when appropriate.
If no tools have been set, the command may return an empty string or a default value (e.g., ""), indicating no tools are configured.
Retrieving the tools configuration serves several critical purposes in managing AI interactions:
•Verification: Ensures the correct tools are available for the AI to use, preventing unintended behavior or missing functionality.
•Debugging: Helps diagnose issues when the AI fails to invoke expected tools, such as malformed JSON or missing descriptions.
•Workflow Management: Allows scripts to dynamically adjust based on the available tools, ensuring compatibility with specific tasks or queries.
•Documentation: Provides a snapshot of the current toolset for logging or user feedback purposes.
Use the Get Tools command to retrieve the current tools configuration at any point after it has been set with AIX.Set Tools. This is particularly useful before executing AIX.Ask or AIX.AskVision, especially when queries may trigger tool calls.
Store the returned JSON string in a variable for further processing, such as parsing with MiniRobotLanguage’s JSON functions (e.g., JSON.Parse) or displaying it for user review. If no tools are configured, the command will return an empty string or a default placeholder, which can be checked to handle edge cases.
Example Usage
Example 1: Basic Tool Retrieval
AIX.Set Tools|""[{""name"": ""get_time"", ""description"": ""Get the current time""}, {""name"": ""get_weather"", ""description"": ""Get current weather""}]""
AIX.Get Tools|$$TOOLS
DBP.Current tools configuration: $$TOOLS
AIX.Ask|""What time is it and what is the weather?""
This example sets a configuration with two tools, retrieves it, displays the JSON string, and sends a query that may trigger tool calls.
Example 2: Handling Empty Configuration
AIX.Set Tools|""
AIX.Get Tools|$$TOOLS
IF $$TOOLS = """" THEN
DBP.No tools are configured
ELSE
DBP.Tools configured: $$TOOLS
END IF
This example clears the tools configuration, retrieves it, and checks if it’s empty, providing a fallback message.
Illustration
┌────────────────────┐
│ Tools Retrieval │
├────────────────────┤
│ Input: Global Var │───────▶
│ Process: Fetch │
│ Output: JSON String│◀──────┤
└────────────────────┘
│
▼
[Variable Storage]
A detailed visual of the process: fetching the tools configuration from a global variable and storing it in a user-defined variable as a JSON string.
Syntax
AIX.Get Tools|$$variable
AIX_Get_Tools|$$variable
Parameter Explanation
$$variable - (Required) A variable (e.g., $$TOOLS) of type WSTRING where the current tools configuration, returned as a JSON string, will be stored. This variable can then be parsed or displayed as needed. Ensure the variable is large enough to hold the JSON string, which may vary depending on the number and complexity of tools defined.
Remarks
- The tools configuration is initially set by AIX.Set Tools and is used by the HTP_AnalyzeGrokResponse subroutine to process tool_calls returned by the Grok API. This ensures the AI can invoke the correct tools based on the query.
- The returned JSON string is unescaped and mirrors the format provided to AIX.Set Tools, including all defined tools and their properties (e.g., name, description, arguments).
- If the tools configuration is empty or has not been set, the command returns "", allowing scripts to handle this case gracefully (e.g., by prompting the user to configure tools).
- The command is non-destructive and does not modify the configuration; it only retrieves the current state.
Limitations
- The command reflects only the current tools configuration set by AIX.Set Tools; it does not indicate whether the Grok API successfully uses these tools or if they are valid.
- If the JSON string is malformed or exceeds system memory limits, the command may return an error or truncated data, requiring error handling in the script.
- The command does not provide real-time feedback on tool invocation success; this must be inferred from the response content or additional error-checking commands.
See also:
• AIX.Ask
• Model Configuration and Tools