|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Tool and Function Management > AIU. - Artificial Intelligence Utility |
MiniRobotLanguage (MRL)
AIU.GetToolChoice
Retrieve the Current Tool Choice Setting
Intention
GetToolChoice Command: Accessing the Current Tool Preference
The GetToolChoice command retrieves the current tool choice setting used by AIU operations, such as AIU.Chat or AIU.GenerateResponses, when interacting with tools or functions.
This setting determines how the AI prioritizes or selects tools during response generation.
It’s part of the AIU - OpenAI API suite.
The GetToolChoice command fetches the current tool choice configuration, which could have been set by a corresponding AIU.SetToolChoice command or initialized to a default value.
The result can be stored in a variable or, if unspecified, placed on the Top of Stack (TOS).
Retrieving the tool choice setting is useful for:
•Verification: Confirm the tool preference before invoking tool-related operations.
•Debugging: Log the tool choice for troubleshooting tool usage issues.
•Dynamic Control: Adapt script behavior based on the current tool selection strategy.
The command accepts an optional parameter to store the retrieved tool choice setting.
If no variable is provided, the value is pushed onto the stack. The default is typically set during Init_AIU() unless overridden by AIU.SetToolChoice.
Technical Details
- Format: Returned as a string, typically one of "auto", "none", or a specific tool name (e.g., "calculator").
- Default: "auto" (AI decides tool usage), unless specified otherwise during initialization.
- Options: Based on OpenAI’s API, valid values include:
•"auto": AI selects tools as needed.
•"none": No tools are used.
•Specific tool name: Forces use of a named tool (e.g., "web_search").
For more details, see OpenAI’s official documentation: OpenAI Chat API - tool_choice.
Example Usage
AIU.SetToolChoice|web_search
AIU.GetToolChoice|$$TOL
DBP.Current Tool Choice: $$TOL
AIU.GetToolChoice
POP.$$TOL
This assumes a prior AIU.SetToolChoice to "web_search" and retrieves it using both a variable and the stack.
Illustration
┌────────────────────┐
│ Tool Choice │
├────────────────────┤
│ web_search │
└────────────────────┘
The current tool choice setting retrieved by the command.
Syntax
AIU.GetToolChoice[|P1]
AIU.Get_ToolChoice[|P1]
Parameter Explanation
P1 - (Optional) The variable to store the current tool choice setting. If omitted, the value is placed on the Top of Stack (TOS).
Example
AIU.SetToolChoice|none
AIU.GetToolChoice|$$CHO
DBP.Current Tool Choice: $$CHO
ENR.
Remarks
- Returns the exact string set by AIU.SetToolChoice or the default ("auto").
- Case-sensitive where applicable (e.g., tool names).
Limitations
- Only retrieves the current setting; does not validate tool availability.
- More than one parameter triggers an error.
See also:
• AIU.Chat