Tutorial – Using the OpenAI analytics connector in Qlik Cloud
This tutorial teaches you how to work with the OpenAI analytics connector to enhance your Qlik Sense apps with contextual depth from generative AI models. Specifically, it shows you how to use the connector with two different configurations.
You can integrate your OpenAI analytic connection directly into your data model so that data generated by it is pre-loaded into the app. Alternatively, you can use it in chart expressions. The tutorial shows you how to get set up for working with the connector, and how to create connections with two different configurations. From there, it guides you through basic examples of how to incorporate the functionality into your Qlik Sense apps.
The examples in this tutorial can also be used for working with the Azure OpenAI analytics connector.
Set up your OpenAI platform account and Qlik Cloud environment
Before you can work with the OpenAI analytics connector, you need to complete several steps. These include:
-
Create an OpenAI platform account
-
Obtain an OpenAI API key
-
Enable analytic connection functionality in Qlik Cloud
For full details, see Getting started with the OpenAI platform.
Create the connections
Create connections to the OpenAI analytics connector from the Create page of the Analytics activity center or from the Data load editor. Once you have created the connections, you are ready to start working directly with the OpenAI platform through the load script or in chart objects.
Do the following:
-
Create a new connection to OpenAI from the Data load editor or from the Create page in the Analytics activity center. In the Data load editor, the OpenAI connector is found under Analytics sources.
-
Select the Configuration to use. Use one configuration for each connection that you make. For this tutorial, make a separate connection for each of the examples:
-
Example 1: OpenAI Completions API (GPT-3) - Rows
-
Example 2: OpenAI Completions API (GPT-3) - JSON Tables
-
Example 3: OpenAI Chat Completions API (GPT-3.5, GPT-4) - Rows
-
Interactive example: OpenAI Chat Completions API (GPT-3.5, GPT-4) - Rows
-
-
Authenticate yourself on the connection by entering the OpenAI API key you generated in the preparations section of this tutorial.
-
Adjust the default parameter values to suit your needs.
Information noteYou will almost always need to alter the Max Tokens parameter value in order for the connection to function properly for your needs. This parameter controls the size of the response that will be generated. -
Add an Association Field to link the connection output to the data model of one or your apps. This will depend on which examples you work on.
-
For connections used in examples 1 to 3, enter RowId.
-
For the interactive example, leave this parameter blank.
-
-
For the Name parameter, enter a distinct name value for each connection you create, indicating the configuration the connection uses. You will need to use these parameter values when working in the load script or with chart expressions.
For the purposes of the tutorial examples, use:
-
Example 1: OpenAI Connection for Rows Completions (GPT-3)
-
Example 2: OpenAI Connection for JSON Tables Completions (GPT-3)
-
Example 3: Chat_Completions_GPT_3.5_4_Rows
-
Interactive example: Interactive_Chat_Completions_GPT_3.5_4_Rows
-
-
Click Create.
Examples
Once you have created the connection with this configuration, you can use it in your load script and in chart expressions to communicate with OpenAI models.
An example of each process is shown in the following lessons.
These examples are designed to be stand-alone and can be completed independently of one another.