AIG. - AI Google Gemini Integration

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIG. - Google AI > 4. Configuration (Generation Parameters) >

AIG. - AI Google Gemini Integration

AIG.SetResponseFormat

Previous Top Next


MiniRobotLanguage (MRL)

 

AIG.SetResponseFormat
Set the Desired Response Format (Text or JSON)

 

Intention

 

Specify the desired output format for the AI model's response. This allows you to request either standard plain text or structured JSON output, which can be useful for integrating the AI's response into other automated processes.

 

What is the SetResponseFormat Command?

 

This Command sets the AIG_ResponseFormat global variable. This variable holds a JSON string value (including quotes) representing the desired format, typically corresponding to the `response_mime_type` parameter in the Google API request.

 

If you provide an empty string ("") or omit the parameter, the format resets to the default (`$AIG_Def_ResponseFormat`, usually `"text"`).

 

Valid Formats (as JSON Strings):

$BC & "text" & $BC (Default): Standard plain text response.

$BC & "json_object" & $BC: Instructs the model to generate a response that is a valid JSON object. You usually need to guide the model in your prompt on the desired JSON structure.

 

Why Do You Need It?

 

Use this Command to:

Get Structured Data: Force the AI to output JSON for easier parsing and programmatic use.

Ensure Text Output: Explicitly request plain text if needed.

 

How to Use

 

Provide one of the valid format strings (including the surrounding quotes, e.g., using $BC or $"""...""") as parameter P1.

 

Example Usage

 

// Request JSON output

AIG.SetResponseFormat|$"""json_object"""

DBP. Response format set to JSON object.

// Remember to also guide the model in the prompt, e.g.:

// AIG.Ask|Create a JSON object with keys 'name' and 'city' for a person named Bob in London.|$$JsonResult

 

// Reset to default text format

AIG.SetResponseFormat|""

DBP. Response format reset to default (text).

 

Syntax

 

AIG.SetResponseFormat|P1

AIG.srf|P1

 

Parameter Explanation

 

P1 - (Optional) A JSON string value representing the desired response format.
� �- Must include quotes: e.g., `$"""text"""`, `$"""json_object"""`.
� �- If an empty string (`""`) is provided or the parameter is omitted, resets to the default (`"text"`).

 

Remarks

 

- When requesting `"json_object"`, it's crucial to instruct the model within your prompt about the specific JSON structure you expect.

- The underlying API parameter used might be `response_mime_type`.

- Use AIG.GetResponseFormat to retrieve the current setting.

 

See also:

 

? AIG.GetResponseFormat

? AIG. Commands Overview