Question Method (AIOBJECT)


 

The Question method is used to make an inquiry to an OpenAI or Gemini model using the associated PL/B AIOBJECT object. This method uses the following format:

 

 

[label]

{object}.Question

[GIVING {return}] USING [*Input=]{input}][:

 

 

[*Body=]{body}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. An AIOBJECT object previously declared.

return

Optional. A Numeric Variable that returns a success or fail value.

input

Required. A Character String Variable or literal that specifies the question for AI engine being accessed/used

body

Optional. A Character String Variable or literal that specifies API specific JSON to be added to the AI request.

Flags Affected: EOS, OVER, ZERO

Notes:

  1. The ZERO flag is set to TRUE when the 'return' value is zero used to indicate that the method executed successfully. The ZERO flag is set to FALSE when the 'return' value is not zero indicating that the method execution failed.

  2. The OVER flag is set TRUE if the 'return' variable is too small and cannot contain the 'return' value without being truncated. Otherwise, the OVER flag is set to FALSE.

  3. The EOS flag is always cleared.

  4. The {input} parameter contains the question to be sent to the OpenAI or Gemini model

  5. The optional {body} parameter can contain API specific JSON to be added to the AI request. This allows the program to use any custom features that a specific model might provide.

  6. The error values returned in {return} are defined as follows:

  7.  

    Error

    Description

    1

    Memory allocation error.

    2

    No key. Key must be specified.

    3

    A previous question is still being processed.

    4

    No model. Model must be specified.

    5

    Unknown model name is being used.

    .

 

Example 1:

 

      MyAI.Question Using "What are some other names for red ?"

 

Example 2:

 

     GptQuest.SetString Using "reasoning.effort","low"

     GptQuest.SetString Using "input[0].role","developer"

     GptQuest.SetString Using "input[0].content","Talk like a pirate."

     GptQuest.SetString Using "input[1].role","user"

     GptQuest.SetString Using "input[1].content","Are semicolons optional in JavaScript?"

     GptQuest.GetString Giving aiQuestion

 

     MyAI.Question Using "",aiQuestion

 

 

 

See Also: Method Syntax,, AIOBJECT.



PL/B Language Reference