AIG. - AI Google Gemini Integration

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIG. - Google AI > 8. Results & Analysis >

AIG. - AI Google Gemini Integration

AIG.GetWordCount

Previous Top Next


MiniRobotLanguage (MRL)

 

AIG.GetWordCount
Retrieve the Word Count of the Last Response

 

Intention

 

GetWordCount Command: Response Length Analysis
 
The GetWordCount Command retrieves the estimated number of words contained in the AI's most recent text response. This value is calculated automatically during the response analysis phase and stored in the AIG_WordCount global variable.

This allows you to quickly gauge the length or verbosity of an answer without needing to parse the text yourself.

 

What is the GetWordCount Command?

 

It is a simple getter command that returns an integer value representing the word count. It relies on the internal analysis performed immediately after an API call (like AIG.Ask). The result can be placed in a variable or on the Top of Stack (TOS).

 

Why Do You Need It?

 

Knowing the word count is useful for:

Logic Flow: Decide how to display the text (e.g., use a MsgBox for short answers, or a Notepad window for long essays).

Validation: Verify if the AI followed constraints like "Answer in 5 words or less".

Statistics: Log the verbosity of responses for reporting purposes.

 

How to Use the GetWordCount Command?

 

Simply invoke the command after a successful generation request. Optionally, provide a variable name to store the count.

 

Note: This count is calculated based on space-separated words in the final text. It is NOT the same as "Tokens".

 

Example Usage

 

AIG.Ask|Explain quantum entanglement in one sentence.

AIG.GetWordCount|$$CNT

IVV.$$CNT>20

 DBP.Response was too long ($$CNT words).

ELSE

 DBP.Response was concise ($$CNT words).

EIF.

 

Retrieves the word count to determine if the response met the brevity requirement.

 

Illustration

 

+------------------------+

� "Hello world!" � � � � � -> Word Count: 2

+------------------------�

� "AI is very powerful." � -> Word Count: 4

+------------------------+

Simple estimation of content length.

 

Syntax

 

AIG.GetWordCount[|P1]

AIG.gwc[|P1]

 

Parameter Explanation

 

P1 - (Optional) Variable to store the resulting integer. If omitted, the count is placed on the Top of Stack (TOS).

 

Remarks

 

- This command returns an estimation based on standard text parsing (counting spaces).

- Do NOT use this for billing or API limits. For API limits, use AIG.GetTokens instead.

- Returns 0 if no response has been generated yet.

 

See also:

 

? AIG.Ask

? AIG.GetTokens

? AIG.GetContent