|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Response Analysis > AIU. - Artificial Intelligence Utility |
MiniRobotLanguage (MRL)
AIU.GetWordCount
Retrieve the Word Count of the AI�s Response
Intention
GetWordCount Command: Measure Response Length
The GetWordCount Command retrieves the word count of the AI�s most recent response generated by Commands like AIU.Responses or AIU.ResponsesVision.
It provides a metric for response length in words.
It�s part of the AIU - OpenAI API suite.
The GetWordCount Command calculates and returns the number of words in the text content of the last AI response.
The result is returned as a string to an optional variable or pushed to the Top of Stack (TOS), tied to the session�s latest response, possibly linked to AIU.SetPreviousResponseId.
Retrieving the word count is useful for:
�Analysis: Assess response verbosity or conciseness.
�Validation: Ensure responses meet length requirements.
�Debugging: Monitor output size for optimization.
Call the Command with an optional variable to store the result; if omitted, the word count is pushed to the stack.
It applies to responses from models like gpt-4o or gpt-3.5-turbo, with no additional token cost for retrieval as of March 18, 2025.
Example Usage
AIU.Responses|Tell me about cats|$$CAT
AIU.GetWordCount|$$CNT
DBP.Word Count: $$CNT
Generates a cat description and retrieves its word count (e.g., "15") into $$CNT.
Illustration
+-----------------------------------+
� Response � � � � � � Word Count � �
+--------------------+--------------�
� "Cats are fluffy." � "3" � � � � ��
+--------------------+--------------�
� (unset) � � � � � �� "0" � � � � ��
+-----------------------------------+
Illustration of response word counts, including unset state.
Syntax
AIU.GetWordCount[|P1]
AIU.Get_WordCount[|P1]
Parameter Explanation
P1 - (Optional) The variable where the word count is stored as a string. If omitted, the value is placed on the Top of Stack (TOS).
Example
AIU.Responses|What�s the weather?|$$WEA
AIU.GetWordCount|$$NUM
DBP.Words: $$NUM
ENR.
Remarks
- Returns "0" if no response content is available.
- Word count is based on space-separated tokens in the response text.
Limitations
- Accepts zero or one parameter; extra parameters trigger an error (%IC_ER_PA).
- Reflects only the latest response; older responses need specific IDs.
See also: