|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIO. - OpenRouter AI > AIO Commands |
MiniRobotLanguage (MRL)
AIO.GetToolCalls
Gets tool/function calls from the last chat response (if any).
This command retrieves any tool calls that were generated by the AI in response to the most recent AIO.Chat command. Tool calls are returned as a JSON array containing details about each requested function call, including the function name and arguments.
AIO.GetToolCalls[|$$RET]
Square brackets [] indicate optional parameters.
$$RET (Optional)
Variable to store the JSON array of tool calls. If specified, the JSON array string containing tool call details will be stored in this variable. If omitted, the command still executes but the result is not captured to a variable.
Type: String
JSON array string with tool call details, or empty if no tool calls.
Returns a JSON array containing objects with the following structure for each tool call:
[
{
"id": "call_xxx",
"type": "function",
"function": {
"name": "function_name",
"arguments": "{\"param1\":\"value1\"}"
}
}
]
Returns an empty string if no tool calls were present in the last chat response.
Basic usage example demonstrating tool setup, chat, and retrieval of tool calls:
REM Set up available tools for the AI
AIO.SetTools|[{"type":"function","function":{"name":"get_weather"}}]
REM Send a chat message that may trigger tool calls
AIO.Chat|What's the weather in Paris?|$$Result
REM Retrieve any tool calls from the response
AIO.GetToolCalls|$$ToolData
REM Display the tool calls
DBP.Tool calls: $$ToolData
1. AIO.SetTools defines the available tools/functions the AI can call.
2. AIO.Chat sends a user message; the AI may respond with tool calls instead of or in addition to text.
3. AIO.GetToolCalls retrieves the JSON array of any tool calls from that response.
4. The tool call data can then be parsed and executed as needed.
AIO.SetTools - Defines the list of tools/functions available to the AI.
AIO.Chat - Sends a chat message to the AI and retrieves the response.
AIO.SubmitToolResults - Submits the results of executed tool calls back to the AI.
AIO.GetLastResponse - Retrieves the text content of the last chat response.
Tool calls are only available if the AI model supports function calling and tools were configured via AIO.SetTools.
Always check if the return value is empty before attempting to parse tool calls.
After executing tool calls locally, use AIO.SubmitToolResults to send the results back to the AI.