Response Method (AIOBJECT)


 

The Response method is used to obtain the returned JSON data from last successful OpenAI or Gemini AI operation. This method uses the following format:

 

 

[label]

{object}.Response

[GIVING {return}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. An AIOBJECT object previously declared.

return

Optional. A Character Variable that returns the output JSON string. If an error occurs while generating the JSON output string, the Character Variable is returned as a NULL variable.

 

Flags Affected: EOS, OVER, ZERO

Notes:

  1. The EOS flag is set if the output JSON string is truncated because the {return} variable is too small.

  2. The ZERO and OVER flags are always cleared.

  3. The JSON data for a OpenAI AI operation contains much information, and is described in the on-line OpenAI API documentation. Most PL/B programs will only need to use the field output[1].content[0].text to retrieve the generated text.

  4. The JSON data for a Gemini AI operation contains much information, and is described in the on-line Gemini API documentation. Most PL/B programs will only need to use the field candidates[0].content.parts[0].text to retrieve the generated text.

  5. The JSONDATA object can be used to process the returned data.

 

Example 1:

 

      MyAI.Response Giving jsonData

      MyJson.Parse Using jsonData

      MyJson.GetString Giving answerData Using "output[1].content[0].text"

 

Example 2:

 

     MyAI.Response Giving jsonData

     MyJson.Parse Using jsonData

     MyJson.GetString Giving answerData Using "candidates[0].content.parts[0].text"

 

 

See Also: Method Syntax,, AIOBJECT.



PL/B Language Reference