AIX - Artificial Intelligence and X Platform Utility

<< 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

AIX.Get IsFunctionCall

Previous Top Next


MiniRobotLanguage (MRL)

 

AIX.Get IsFunctionCall
Check if the Response Involves a Function Call

 

Intention

 

Get IsFunctionCall Command: Detect Function Call in Response
 
The Get IsFunctionCall command retrieves a flag indicating whether the latest response from the Grok API involves a function call, as determined by the HTP_AnalyzeGrokResponse subroutine.

This is useful for handling responses that trigger tool executions.

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

 

What is the Get IsFunctionCall Command?

 

The Get IsFunctionCall command returns the value of the AIX_IsFunctionCall global variable, which is set to 1 if the latest response contains a tool_calls field in the JSON response, and 0 otherwise.

This flag is determined during the analysis of the raw response by HTP_AnalyzeGrokResponse, which parses the JSON to detect function call data.

 

Why Do You Need It?

 

Checking for function calls is essential for:

Workflow Control: Determines if additional processing (e.g., tool execution) is required.

Error Handling: Identifies when a response expects a function call that needs implementation.

Automation: Enables scripted handling of function call responses.

 

How to Use the Get IsFunctionCall Command?

 

The command retrieves the AIX_IsFunctionCall flag, which is set after analyzing a response with AIX.Ask or AIX.AskVision.

Use it to store the result in a variable for conditional logic. For example, check if a function call is present and proceed accordingly.

 

Example Usage

 

AIX.SetKey|""your_api_key_here""

AIX.SetModel|""grok-3""

AIX.SetTools|""{""name"": ""get_weather"", ""description"": ""Get current weather""}""

AIX.Ask|""What is the weather like today?""

AIX.Get IsFunctionCall|$$IS_CALL

IF $$IS_CALL = 1 THEN

 DBP.Function call detected in response

 ' Add logic to handle the function call

ELSE

 DBP.No function call, processing text response

END IF

 

This example sets up the system, defines a tool, sends a query that might trigger a function call, checks the result, and handles it conditionally.

 

Illustration

 

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

│ Function Call Check│

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

│ Input: Response    │

│ Process: Parse     │

│ Output: 1/0        │

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

A visual of checking for a function call in the response (1 for present, 0 for absent).

 

Syntax

 

AIX.Get IsFunctionCall|$$variable

AIX_Get_IsFunctionCall|$$variable

 

Parameter Explanation

 

$$variable - (Required) A variable (e.g., $$IS_CALL) of type LONG where the result (0 or 1) will be stored.

 

Example

 

AIX.SetTools|""{""name"": ""get_time"", ""description"": ""Get current time""}""

AIX.Ask|""What time is it now?""

AIX.Get IsFunctionCall|$$IS_CALL

IF $$IS_CALL = 1 THEN

 DBP.Response involves a function call: get_time

ELSE

 DBP.No function call detected

END IF

 

This example sets a tool, sends a query that might trigger it, checks for a function call, and handles the result.

 

Remarks

 

- The AIX_IsFunctionCall flag is set by HTP_AnalyzeGrokResponse when a tool_calls field is present in the JSON response.

- Requires a prior call to AIX.Ask or AIX.AskVision to populate the response data.

 

Limitations

 

- Only detects function calls if the JSON response includes a tool_calls field; malformed or missing data may result in 0.

- The flag is overwritten with each new response analysis, so it reflects only the latest query.

 

See also:

 

AIX.Ask

AIX.AskVision

AIX.SetTools

Tool and Function Management