AIO.GetReason

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIO. - OpenRouter AI >

AIO.GetReason

AIO.GetReason

Previous Top Next


MiniRobotLanguage (MRL)

 

AIO.GetReason

 

Description

Gets the finish reason from the last chat response. This command retrieves the reason why the AI model stopped generating the response, which can be useful for debugging and handling different response scenarios.

 

Syntax

AIO.GetReason[$$RET]

 

Parameters

$$RET - Optional. Variable to store the finish reason string.

 

Return Value

Returns one of the following finish reason values:

stop - The response completed naturally. The model finished generating the output without any interruptions.

length - The response was cut off because it reached the maximum token limit. Consider reducing input length or increasing the max_tokens parameter.

content_filter - The response was filtered due to content policy violations. The output may have been partially or fully suppressed.

tool_calls - The model decided to call a function or tool instead of generating a text response. This indicates that the AI wants to execute a registered tool.

 

Example

AIO.Chat|Tell me a story|$$Result

AIO.GetReason|$$WhyStopped

DBP.Finish reason: $$WhyStopped

 

1. Sends a chat request with the prompt "Tell me a story" and stores the response in $$Result

2. Retrieves the finish reason from the last chat response and stores it in $$WhyStopped

3. Displays the finish reason using DBP (Debug Print)

 

Remarks

The finish reason is only available after a successful call to AIO.Chat. The return value indicates why the AI model stopped generating tokens, which helps determine how to handle the response appropriately.

 

See Also

AIO.Chat

AIO.GetToolCalls

AIO.GetUsage

AIO.ClearHistory