AIX - Artificial Intelligence and X Platform Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIX. - Grok / X - API > !Output Formatting and Delivery >

AIX - Artificial Intelligence and X Platform Utility

AIX.Get WordCount

Previous Top Next


MiniRobotLanguage (MRL)

 

AIX.Get WordCount
Retrieve the Word Count of the AI’s Response

 

Intention

 

Get WordCount Command: Measure Response Length
 
The Get WordCount command retrieves the number of words in the latest response from the Grok API, as calculated by the HTP_AnalyzeGrokResponse subroutine.

This aids in assessing response verbosity or content length.

It’s part of the AIX - Grok / X - API suite.

 

What is the Get WordCount Command?

 

The Get WordCount command returns the value of the AIX_WordCount global variable, which counts the words in the response text by parsing the grokContent using spaces as delimiters.

It applies only to text or vision responses, not function call responses.

 

Why Do You Need It?

 

Retrieving the word count is useful for:

Content Analysis: Evaluates the length of the AI’s output.

Validation: Ensures responses meet minimum or maximum word requirements.

Optimization: Adjusts query parameters based on response length.

 

How to Use the Get WordCount Command?

 

Use the command to retrieve the word count after executing an AI query with AIX.Ask or AIX.AskVision that returns text content.

Store the result in a variable for further processing or display.

 

Example Usage

 

AIX.SetKey|""your_api_key_here""

AIX.SetModel|""grok-3""

AIX.Ask|""Tell me about space exploration.""

AIX.Get WordCount|$$WORDS

DBP.Word count: $$WORDS

 

This example sets up the system, sends a query, retrieves the word count, and displays it.

 

Illustration

 

┌────────────────────┐

│ Word Count         │

├────────────────────┤

│ Input: Response    │

│ Process: Parse     │

│ Output: Word Num   │

└────────────────────┘

A visual of parsing the response to count words.

 

Syntax

 

AIX.Get WordCount|$$variable

AIX_Get_WordCount|$$variable

 

Parameter Explanation

 

$$variable - (Required) A variable (e.g., $$WORDS) of type LONG where the word count will be stored.

 

Remarks

 

- The word count is calculated by parsing the grokContent with spaces as delimiters, applicable only to text or vision responses.

- Requires a prior call to AIX.Ask or AIX.AskVision to populate the response data.

 

Limitations

 

- Returns 0 for function call responses, as word counting is not applicable.

- Depends on space-based parsing, which may misinterpret complex punctuation or multi-word phrases.

 

See also:

 

AIX.Ask

AIX.AskVision

Response Analysis