Initialize Method (AIOBJECT)
The Initialize method is used to create a runtime Web View AI thread. This AI thread contains the required functions to interface with the supported AI engines using the PL/B AIOBJECT object. This method uses the following format:
|
|
|
|
|
|
|
|
|
|
|
|
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.
model
Required. A Character String Variable or literal that specifies a supported AI engine being accessed/used.
key
Required. A Character String Variable or literal that specifies the API private key required to access/use the AI engine. This key is a secret credential that lets your AIOBJECT make requests to OpenAI’s or Gemini's models.
instructions
Optional. A Character String Variable or literal that specifies string data to describe the expected behavior of the AI engine when answering the PL/B input questions.
Flags Affected: EOS, OVER, ZERO
Notes:
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.
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.
The EOS flag is always cleared.
To get an OpenAI API key for the {key} parameter, sign up for a developer account at platform.openai.com, navigate to the "API keys" section in the dashboard, and click "Create new secret key". Copy the key immediately and store it securely, as it will not be displayed again.
To get a Gemini API key for the {key} parameter, visit Google AI Studio, sign in with your Google account, and click "Get API key" on the left menu. Select "Create API key" in a new or existing Google Cloud project to generate your key, which can be used for accessing Gemini models.
The optional {instruction} parameter can contain the behavior rules used by the AI engine when answering the input questions using the AIOBJECT. This parameter gives the model high-level instructions on how it should behave while generating a response, including style, formatting, and examples of correct responses These instructions will be used by the Question method.
The error values returned in {return} are defined as follows:
|
Error |
Description |
|
1 |
Memory allocation error. |
|
2 |
No key. Key must be specified. |
|
4 |
No model. Model must be specified. |
|
1nn |
This is a Windows OS Web View startup error. Verify that the Web View is installed on the Windows OS system being used. |
.
Example 1:
Example 2:
See Also: Method Syntax,, AIOBJECT.
![]() |