OpenAI's generative AI models - ChatGPT and Dall-E - can be used within Displayr. This article describes:
- OpenAIs models: ChatGPT and Dall-E
- Connecting Displayr to OpenAI
- Creating Outputs using OpenAI via menus (e.g., Interpret, Summary, Data Analysis, R Code)
- Modifying outputs created by AI
- Creating variables using ChatGPT via menus (e.g., Sentiment, Clean Text Data)
- Using OpenAI via code
OpenAIs models: ChatGPT and Dall-E
ChatGPT allows users to perform automation by giving instructions (prompts) in plain English and other supported languages. It's particularly useful for translation, writing code, summarization, interpretation, data analysis, and working with text data.
Dall-E generates images based on inputs, such as text and data.
When using these features, please keep in mind that they are prone to hallucinations. Results need to be checked.
Connecting Displayr to OpenAI
Requirements
To use ChatGPT and Dall-E you need to:
- Have an OpenAI account with API credits.
- Connect Displayr to OpenAI.
Please note: OpenAI API credits and a paid ChatGPT account are two different products. A paid ChatGPT account cannot be used to access OpenAI through Displayr. OpenAI API credits are purchased separately.
See Connecting Displayr to OpenAI for the full process of connecting ChatGPT and Dall-E to Displayr.
Creating Outputs using OpenAI via menus
OpenAI can generate outputs that can be placed on pages. These are dynamic outputs that will automatically update if their inputs change, unless Calculate automatically is unchecked.
OpenAI is accessed from the AI menu in the toolbar.
Basic Prompt
When you select AI > Basic Prompt, an output appears on the page. Enter text into the Prompt in the object inspector. This gives you access to ChatGPT. You can change the output formatting in the Appearance tab (line wrapping is in the Layout section). The Temperature prompt governs how much randomness goes into the result selection by ChatGPT (larger values mean it's more "creative").
Image
Selecting AI > Image allows you to create images via Dall-E. By default, Optimize prompt using ChatGPT setting is checked, which means that the prompt is first improved by ChatGPT, and then sent to OpenAI.
You can customize the output by controlling the aspect ratio (Size), Scaling, and Temperature.
Furthermore, you can connect the visualization to data by selecting Additional inputs (how data is used is described in the next few sections).
Data Analysis
AI > Data Analysis allows you to select variables as inputs and instructs the AI how to analyze the data (e.g., create a crosstab, estimate linear regression, etc.).
Please remember that AI's hallucination problem is most serious with this feature, and results must be carefully scrutinized.
Interpret
AI > Interpret generates the interpretation of data analyses, such as crosstabs and regression.
Summary
AI > Summary summarizes inputs. For example, if you have a report with text summaries on many pages, Summary can be used to create an executive summary.
R CODE
AI > R Code generates code in the R language. This can be useful for creating or checking code for calculations, calculation grids, and R variables.
QScript
AI > QScript can generate automation code in Displayr's API language (QScript).
Custom
AI > Custom allows you to provide inputs of text data, text variables, and any other data type. It is the most general of the outputs (i.e., all the other AI-generated outputs are optimized for specific problems).
Modifying outputs created by AI
You can customize outputs created by OpenAI by:
- Changing the inputs (e.g., the data selected or the Prompt).
- Changing other properties in the object inspector, such as settings available in the Appearance tab (e.g., text wrapping, font, color).
- Right-clicking on the output, selecting either Copy > Data or Copy > Image, and then right-clicking and selecting Paste will result in a normal textbox or an image output that can be resized.
Creating variables using ChatGPT via menus
ChatGPT can be used to create variables. This causes whatever prompt you provide to be applied to each row of data in a variable.
These work by selecting a variable in the Data Sources tree and pressing + > AI and your desired option.
In the example below, AI > Variables > Clean Text Data has been used to identify bad data (1s), and the next step would typically be used to delete the poor-quality data.
In some cases, it's clearly the case that the data identified as bad is bad (e.g., xxxx, ad). In other cases, it's not so clear. The prompt can be edited to give clearer instructions, although sometimes this will be ineffective (due to hallucination or your prompt being insufficiently clear).
Using OpenAI via code
The examples above access ChatGPT and Dall-E by pointing and clicking. They can also be accessed by writing code in calculations. There are two functions: AIVariable and AIOutput.