|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIG. - Google AI > A.Tools-Configuration > AIG. - AI Google Gemini Integration |
MiniRobotLanguage (MRL)
AIG.GetToolParam
Extract Function Argument
Intention
To easily retrieve the value of a specific argument passed by the AI when it calls a tool. This eliminates the need for you to parse the complex JSON response string manually.
When the AI calls a function, it provides data in a JSON object structure called `args`. This command looks up a specific key (Parameter Name) within that structure and returns its value.
For example, if the AI output is:
{ "name": "set_light", "args": { "color": "red", "brightness": 50 } }
Using AIG.GetToolParam|color|$$VAL will set $$VAL to "red".
�Simplicity: You don't need to know JSON parsing commands.
�Reliability: Handles string extraction, number conversion, and error checking internally.
�Workflow: Essential for the Tool Handler subroutines to know *what* to do.
' Assume tool "set_weather" was called with { "city": "Berlin", "days": 3 }
AIG.MapToolHandler|set_weather|:Tool_Weather
AIG.DoToolCall
ENR.
:Tool_Weather
' Extract parameters by name
AIG.GetToolParam|city|$$CITY
AIG.GetToolParam|days|$$DAYS
DBP. Getting forecast for $$CITY for $$DAYS days.
RET.
Syntax
AIG.GetToolParam|P1|P2
AIG.gtprm|P1|P2
Parameter Explanation
P1 - (String) The name of the parameter (key) to retrieve (e.g., "location"). Case-insensitive in most cases, but best to match definition.
P2 - (Variable) The variable to store the result value (e.g., `$$VAL`). If the parameter is missing, this will be empty.
See also:
? AIG.GetToolParamsToArr (Get all params at once)