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.GetRawReturn

Previous Top Next


MiniRobotLanguage (MRL)

 

AIG.GetRawReturn
Retrieve the full JSON response string from the AI.

 

Intention

 

GetRawReturn: Accessing the API Under-the-Hood
 
The GetRawReturn Command allows you to retrieve the exact, unmodified JSON text returned by the Google Gemini servers during the last API call.

While commands like `AIG.GetContent` extract just the answer text, `AIG.GetRawReturn` gives you the complete data structure. This includes metadata, safety ratings, citation sources, and detailed error messages that might otherwise be hidden.

 

What is the GetRawReturn Command?

 

When you call `AIG.Ask` or `AIG.AskVision`, the library receives a large packet of data formatted as JSON. It internally parses this to find the answer.

`AIG.GetRawReturn` simply returns that entire packet as a string variable. It connects to the internal variable `AIG_LastDecodedResponseW`.

 

Why Do You Need It?

 

Advanced Debugging: If the AI returns an empty string via `GetContent`, the Raw Return will often show why (e.g., a specific `blockReason` or `finishReason`).

Safety Analysis: Inspect detailed safety scores (Harm Categories) returned by Google.

Citations: Sometimes the model provides links or citations for its facts in a separate JSON field.

Custom Parsing: If Google adds new features to the API that this library doesn't explicitly support yet, you can still access the data via this command.

 

 

 

Syntax

AIG.GetRawReturn[|P1]

AIG.grr[|P1]

 

Parameter Explanation

 

P1 - (Optional) Variable name to store the JSON string. If omitted, the result is placed on the Top-Of-Stack (TOS).

 

Remarks

The returned string is standard JSON.

You can use the built-in `W_JSON` library or JSON parser commands to extract specific data fields from this string.

If the API call failed due to a network error (e.g., timeout), this variable might be empty.

 

Example Usage

 

' 1. Ask a question

AIG.Ask|Tell me a short joke.|$$Result

 

' 2. Retrieve the invisible JSON structure

AIG.GetRawReturn|$$Raw

 

' 3. Inspect it (e.g. print to output or save to file)

DBP. The raw server response was:

DBP. $$Raw

 

' Example Output Format:

' {

' "candidates": [

' {

' "content": { "parts": [ { "text": "Why did the chicken..." } ] },

' "finishReason": "STOP",

' "safetyRatings": [ ... ]

' }

' ],

' "usageMetadata": { "totalTokenCount": 12 }

' }

 

 

See also:

AIG.GetContent

AIG.GetFinishReason

AIG.Ask