User Guide - OpenAI Integration

Introduction

The CAST Imaging integration with OpenAI technology (we support both OpenAI and **Azure OpenAI**provides an automated explanation of the objects in your source code via the Legends > Source Code panel. For example:

Click to enlarge

Prerequisites

Internet connection - you may need to whitelist the following URLs depending on your chosen OpenAI provider:

Access to the application's source code - see Configure the source code viewer.

An OpenAI or an Azure OpenAI API key. Only one service can be used at any one time and the key is defined at a global level (i.e. for ALL applications deployed in CAST Imaging).

OpenAI

To generate a free tier API key:

  • Go to https://openai.com and click SIGN UP (if you do not have a OpenAI account) or LOG IN (If you have already signed up)
  • Choose the type of key you require:

  

  • When logged in, click View API keys in the user menu:

  • Click Create new secret key:

  • Copy/Save the API key in an accessible location:

Azure OpenAI (available in ≥ 2.18)

The following is required to obtain an Azure OpenAI API key:

  • An Azure subscription - Create one for free.

  • Access granted to Azure OpenAI in the desired Azure subscription. Currently, access to this service is granted only by application. You can apply for access to Azure OpenAI by completing the form at https://aka.ms/oai/access.

  • An Azure OpenAI Service resource with either the gpt-35-turbo or the gpt-4 models deployed. For more information about model deployment, see the resource deployment guide.

See https://azure.microsoft.com/en-in/products/cognitive-services/openai-servicefor more information.

  • For Azure OpenAI and OpenAI to work with Chatbot in Imaging you must use the GPT-4 deployment model.
A user with the ADMIN or SUPER ADMIN role is required to configure the OpenAI/Azure OpenAI API key in the Admin Center.

Configure your API key in the Admin Center

Add your chosen API key via the AI Options panel in the License management panel in the Admin Center:

Depending on the type of API key you are entering, the interface differs slightly:

Open AI

Enter your API key and click Update:

Azure OpenAI

You need three pieces of information:

  • API Key
  • Endpoint URL: usually this will take the form https://<app_name>.openai.azure.com
  • Deployment Name: usually this will take the form <app_name>

Enabling OpenAI in the Admin Center

In ≥ 2.20

The tile ‘AI features’ in the admin center allows you to input the API key for AI options. The “AI features” tile also provides an option to enable/disable AI features such as “Explain Code with AI” and “Assistant Chatbot” per tenant.

In ≤ 2.19

By default, the OpenAI integration is disabled by default even if you have input a valid API key. To use the feature you must also enable it using the toggle option in the Applications panel in the Admin Center:

Using the OpenAI feature

To view the results, use the “Explain with ChatGPT” or the “Explain with Azure” option in the Object right click contextual menu when working at object level:

The object’s source code is then displayed in the Legends > Source Code panel, and the AI description will automatically load:

Explanation of the code will first be given in a short summary format and a message is displayed asking if you want to save the explanation(see Saving the OpenAI description as an annotation below) or display the explanation in points:

Code explanation in detailed points:

Using OpenAI to visualise

In ≥ 2.19, an icon is provided, clicking on the icon opens the Chatbot window.

Chaptbot window can be resized and dragged within the canvas. Chatbot comes with a set of inbuilt questions (related to history and follow-up) and also lets you type your query.

Visualise option lets you visualise the selected objects and you may also ask it to explain about the same. You may switch the application and it will recreate the chapbot.

Running OpenAI on a portion of source code

Instead of running the feature on an entire object, you can also mark/select a portion of an object’s source code in the Legends > Source Code panel and obtain an OpenAI explanation about that specific piece of code. When you mark/select a portion of a source code the OpenAI icon is displayed:

Click the icon to view the OpenAI description:

Saving the OpenAI description as an annotation

It is possible to save the OpenAI description as an object level annotation by clicking the tick icon highlighted below:

The description will then be copied/saved in an annotation:

Click to enlarge

Error handling

You receive the following notification messages for the corresponding errors.

ErrorNotification
If internet connection is not present“There is no Internet connection, please contact administrator.”
If source code is too large“Source code is too large to explain”
If OpenAI servers are busy“GPT engine is overloaded, please try after sometime.”
Invalid API key“Invalid GPT key, please contact administrator”