|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIG. - Google AI > 8. Results & Analysis > AIG. - AI Google Gemini Integration |
MiniRobotLanguage (MRL)
AIG.IsFuncCall
Check if the Last Response was a Function Call
Intention
IsFuncCall Command: Detect Tool Use
The IsFuncCall Command checks whether the most recent AI response was a request to execute a tool (Function Call) rather than a standard text reply.
This allows scripts to differentiate between conversation and automation tasks when using Gemini's Function Calling capabilities.
It is part of the AIG - Google Gemini API suite.
This command inspects the internal state of the last API transaction. If the AI model determined that one of the defined Tools (set via AIG.SetTools) should be invoked, the API returns a structured Function Call object instead of plain text.
AIG.IsFuncCall returns 1 if a tool call was detected, and 0 if the response was normal text.
This is critical for building autonomous agents:
�Logic Branching: Decide whether to show the output to the user (Text) or execute a script (Function Call).
�Automation: Automatically trigger Robot actions based on natural language prompts.
�Error Prevention: Prevents displaying raw JSON arguments to the user when the AI intended an action.
Call this command immediately after AIG.Ask. Provide a variable to receive the result (0 or 1).
If the result is 1, you can then use AIG.Get Content to retrieve the JSON arguments for the tool.
Example Usage
' Define a tool for the AI
AIG.SetTools|{ ... definition for "run_notepad" ... }
' Ask the AI to do something
AIG.Ask|Please start Notepad for me.
' Check if AI wants to use the tool
AIG.IsFuncCall|$$IST
IVV.$$IST=1
' AI wants to run the tool
AIG.Get Content|$$JSO
DBP.Executing Tool with args: $$JSO
' ... Logic to parse JSON and run Notepad ...
ELSE
' AI just replied with text
AIG.Get Content|$$TEX
DBP.AI says: $$TEX
EIF.
Illustration
+---------------+
� AI Response � �
+---------------+
� � � ��
�< IsFuncCall? >
�? � � � � � ?
YES (1) � � �NO (0)
�� � � � � � � �
[Execute] � [Display]
Determines the next step in the workflow.
Syntax
AIG.IsFuncCall[|P1]
AIG.gif[|P1]
Parameter Explanation
P1 - (Optional) Variable to store the boolean result.
1 = The response was a Function Call.
0 = The response was standard text.
Remarks
- This command resets automatically when a new API call is made.
- It only returns 1 if Tools were defined via AIG.SetTools and the AI chose to use them.
See also: