User Guide - OpenAI Integration

Available in ≥ 2.16

Introduction

IMPORTANT: This feature is available only if your CAST Imaging administrator has entered an OpenAI / Azure OpenAI API key for your organization in the License management panel in the Admin Center. Your administrator must ensure that sending snippets of source code to OpenAI / Azure OpenAI is allowed by your organization. By entering an OpenAI / Azure OpenAI API key, the administrator enables CAST Imaging user to be able to send snippets of source code to OpenAI / Azure OpenAI, via the CAST Imaging interface. CAST Imaging does not provide any specific governance of such use.

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

(tick)

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

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

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-service for more information.

  • For Azure OpenAI and OpenAI to work with Chatbot in Imaging you must use the GPT-4 deployment model.
(tick)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>

  • If you attempt to enter an API key when the system is not connected to the internet, the following pop-up message is displayed:

  • If you enter an invalid API key, the following pop-up message is displayed:

  • If you enter an expired or disabled API key, the following pop-up message is displayed.

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:

The toggle functionality is per tenant meaning that when enabled, the OpenAI feature will only be available for the specific tenant you are currently focused on. If you need to use the feature in an application that is located in a different tenant, you should move into the required tenant and then enable the toggle:

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:

When the feature is disabled for a tenant, the application/s listed under the tenant will not have the Explain with ChatGPT/Explain with Azure option in the contextual menu when working at object level. See User Guide - Application scope.

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

 

In ≥ 2.20

  • Language support is provided for the "Explain with ChatGPT/Azure" feature. "Preferred Language for Explain with Open" is added to the Preferences, which allows you to choose your preferred language. The supported languages include English, Chinese, Italian, German, and French. This feature is available for both OpenAI and Azure AI.
  • CAST utilizes the ChatGPT Model (Built on ChatGPT 4) to power its Assistant Chatbot. Behind the scenes, CAST feeds specific data from the Neo4J results storage database into the model. This database holds extracted data from analyses, including relationships and objects. The model processes this data to respond to queries. Consequently, there is no transfer of source code when using the Assistant Chatbot.

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"