AI Service Home Bind

The AI Service Home bind is used with Azure Open AI or Azure Vision, which both require customers to independently obtain an API key through Azure. Refer to the Azure OpenAI Integration topic or the Azure Vision Integration topic in the Artificial Intelligence documentation for more information.

The bind can be found within the 'Binds to' dropdown, as shown below.

Configuration

To use any bind:

  1. Create a business rule as defined in the Creating a Business Rule, Function, or Library topic.

  2. Edit the business rule as defined in the Editing a Business Rule or Function topic.

  3. In the Edit Operation dialog, add the bind to a business rule, as defined in the Adding a Bind topic in the Resource Materials online help documentation.

  4. In the Edit Operation dialog, optionally add Messages, as defined in the Localized Messages for JavaScript Business Rules topic.

  5. In the Edit Operation dialog, add JavaScript to call the bind.

Example

The following is an example JavaScript that uses this bind.

Important: Example scripts should not be used as-is without thorough testing, including updating the script to match object and link types that exist on your system. JavaScript variable names are case-sensitive.

The business rule below translates English to German and is used in one of the example package setups for Azure OpenAI.

Copy
// Generate Translation Action version 1.0 AI Text Generation.
// NOTE: A bind must be made to the relevant gateway integration endpoint and attributes for this to produce a translation.
// Translation will be stored in the attribute with the binding id "aiDescription".

function setValueInContext(contextID, value) {
   manager.executeInContext(contextID, function(contextManager) {
       return contextManager.getObjectFromOtherManager(currentObject).getValue(aiDescription.getID()).setSimpleValue(value);
   });
}

var systemInstruction = "You are an AI assistant that translates English to German.";

var generationRequest = currentObject.getValue(description.getID()).getSimpleValue();

if (generationRequest == null) {
   logger.info("Nothing to generate");
   return;
}

generationRequest = "Translate the following:\n" + generationRequest;

var result = aiService.buildTextGenerationRequest(openAIEndpoint).withSystemMessage(systemInstruction).withMessage(generationRequest).execute();

setValueInContext("DE All All", result);

logger.info(result);