AIU. - Artificial Intelligence Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Response Analysis >

AIU. - Artificial Intelligence Utility

AIU.GetLastResponse

Previous Top Next


MiniRobotLanguage (MRL)

 

AIU.GetLastResponse
Retrieve the Full Decoded Response

 

Intention

 

Accessing the Complete API Response
 
The AIU.GetLastResponse command retrieves the complete, decoded JSON response from the most recent successful AIU API call. While other commands like AIU.GetContentS extract just the primary content, this command provides the entire data structure.

 

Why You Need It

 

Retrieving the full response is valuable for:

Debugging: Inspect the entire API response, including metadata like model name, system fingerprint, or error details.

Custom Parsing: Use PSJ commands to extract specific fields not provided by standard AIU result getters.

Analysis: Log or analyze the raw data for performance or behavior insights.

 

How to Use It

 

After a successful API call, simply call the command. You can store the result in a variable or have it placed on the Top of Stack (TOS).

 

Syntax

 

AIU.GetLastResponse[|$$RET]

 

Parameter Explanation

 

P1 ($$RET) - (Variable, String, Optional)
The variable where the full, decoded JSON response will be stored. If omitted, the response is placed on the Top of Stack (TOS).

 

Example

 

' Make a call to the Chat API

AIU.Ask|Who are you?|$$RES

 

' Get the full JSON response for inspection

AIU.GetLastResponse|$$JSN

 

' Now parse the full response with PSJ commands

PSJ.Parse|$$JSN|$$H_1

JIZ.$$H_1|Lab_failed

PSJ.GetStr|$$H_1|model|$$VAL

MBX.Model used:|$$VAL

PSJ.Free|$$H_1

END.

 

Remarks

 

- This command does not make a new API call. It retrieves the stored result from the most recent successful AIU command that communicated with an API.

- The returned string is decoded (typically from UTF-8) and is ready to be parsed by PSJ.Parse.

- This is different from HTP.GetS, which would return the raw, un-decoded bytes from the HTTP layer.

 

See also:

 

AIU.GetContentS

HTP.GetS

PSJ.Parse