|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Response Behavior Settings > AIU. - Artificial Intelligence Utility |
MiniRobotLanguage (MRL)
AIU.GetMaxToken
Retrieve the Current Maximum Token Limit
Intention
GetMaxToken Command: Check Response Length Limit
The GetMaxToken command retrieves the current maximum token limit set for AI responses, aiding in cost and output management.
This is useful for verifying settings or dynamically adjusting script behavior.
It’s part of the AIU - OpenAI API suite.
The GetMaxToken command returns the current maximum token limit configured via AIU.SetMaxToken.
Tokens represent text units (e.g., words or symbols), and this limit caps AI output. The value can be stored in a variable or placed on the Top of Stack (TOS).
Retrieving the max token limit is valuable for:
•Cost Monitoring: Understand output constraints to estimate API costs.
•Verification: Confirm the limit before running AI operations.
•Debugging: Ensure unexpected truncation aligns with the set limit.
Call the command with an optional variable to store the result. If omitted, the value is pushed to the stack.
Token costs depend on the model (see AIU.SetModel). For instance, with gpt-3.5-turbo, 1000 tokens cost $0.0015 for output.
Example Usage
AIU.SetMaxToken|200
AIU.GetMaxToken|$$MAX
DBP.Max Token Limit: $$MAX
AIU.GetMaxToken
POP.$$MAX
DBP.Max Token from Stack: $$MAX
Sets and retrieves a 200-token limit for verification.
Illustration
┌──────────────┬──────────────┐
│ Setting │ Value │
├──────────────┼──────────────┤
│ Max Tokens │ 200 │
├──────────────┼──────────────┤
│ Retrieved │ 200 │
└──────────────┴──────────────┘
Illustration of setting and retrieving a 200-token limit.
Syntax
AIU.GetMaxToken[|P1]
AIU.Get_MaxToken[|P1]
Parameter Explanation
P1 - (Optional) The variable where the max token limit will be stored. If omitted, the value is placed on the Top of Stack (TOS).
Example
AIU.SetMaxToken|150
AIU.GetMaxToken|$$LIM
DBP.Current Max Tokens: $$LIM
ENR.
Remarks
- Returns the value as a numeric string (e.g., "150").
- Reflects the last setting from AIU.SetMaxToken or the model’s default.
Limitations
- Only accepts zero or one parameter; extra parameters cause an error.
- Does not indicate if the limit exceeds the model’s context window.
See also:
• AIU.Chat