AIX. - Grok / X - API

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIX. - Grok / X - API > !Tool and Function Management >

AIX. - Grok / X - API

AIX.SetToolChoice

Previous Top Next


MiniRobotLanguage (MRL)

 

AIX.Set ToolChoice
Set the Preferred Tool Choice for the AI

 

Intention

 

SetToolChoice Command: Configuring Tool Preference
 
The Set ToolChoice command specifies how Grok should handle tool usage in responses, such as enabling, disabling, or selecting specific tools.

This allows you to control whether and which tools the AI employs.

It’s part of the AIX - Grok / X - API suite.

 

What is the SetToolChoice Command?

 

The Set ToolChoice command sets the AIX_ToolChoice global variable, determining Grok’s tool usage behavior in API requests.

Valid options are "none", "auto", "required", or "name":, defaulting to "auto" if invalid.

 

Why Do You Need It?

 

Configuring tool choice is important for:

Control: Disable tools with "none" or force specific ones with "name".

Flexibility: Let Grok decide with "auto" or mandate tool use with "required".

Precision: Tailor responses to use predefined tools like get_weather.

 

How to Use the SetToolChoice Command?

 

Provide a valid tool choice string, which is stored in AIX_ToolChoice and sent with API requests.

Requires tools to be defined via AIX.Set Tools for specific tool names.

 

Example Usage

 

AIX.Set Tools|[{"type":"function","function":{"name":"get_weather","description":"Get weather"}}]

AIX.Set ToolChoice|"name":"get_weather"

DBP.Tool choice set to: get_weather

 

This configures Grok to prefer the get_weather tool in responses.

 

Illustration

 

┌───────────────────────┐

│ Tool Choice           │

├───────────────────────┤

│ "name":"get_weather"  │

└───────────────────────┘

Setting Grok to use a specific tool.

 

Syntax

 

AIX.SetToolChoice[|P1]

AIX.Set ToolChoice[|P1]

 

Parameter Explanation

 

P1 - (Optional) The tool choice string: "none", "auto" (default), "required", or "name":. Invalid inputs revert to "auto".

 

Example

 

AIX.Set ToolChoice|"none"

DBP.Tools disabled

ENR.

 

Remarks

 

- Must align with tools set via AIX.Set Tools.

- Affects responses in AIX.Ask and AIX.Ask Vision.

 

Limitations

 

- Tool names must match those in AIX_Tools or the setting is ignored.

- Effectiveness depends on Grok’s tool support.

 

See also:

 

AIX.Get ToolChoice

AIX.Set Tools

AIX.Ask

AIX.Get IsFunctionCall