OpenAI (BETA)PRO

This knowledge base article relates to the WS Form OpenAI (BETA) add-on. This add-on is free to download.

The WS Form OpenAI add-on allows you to integrate the core OpenAI endpoints into your WordPress forms for the purposes of generating text and image content.

What is OpenAI?

Let’s ask OpenAI what it is…
Human: What is OpenAI?
AI: OpenAI is a nonprofit artificial intelligence research organization. It works on developing friendly AI systems to enhance human well-being, as well as create responsible, equitable AI solutions. OpenAI strives to operate transparently and collaboratively with the global AI research community. OpenAI's main research areas are robotics, reinforcement learning, natural language processing, computer vision, and generative modeling.

Example Use Cases

Example use cases include:

  • Produce text and image content when creating a post using the post management add-on
  • Provide the ability to improve copy in a text area field using instructions (e.g. Fix my grammar!)
  • Create an avatar image when using the user management add-on
  • Question and answer capability on a support page
  • Moderate form submissions for inappropriate content

Demo

The OpenAI Completion endpoint is an AI-powered search engine that uses natural language processing to help you find the answers you need. It can return a list of possible answers, including relevant webpages, articles, and other sources of information, so you can find what you’re looking for quickly and easily.

The OpenAI Chat Playground is an interactive tool that helps you explore and create AI-powered conversations. It allows you to customize chatbot responses, experiment with natural language processing models, and fine-tune your conversational skills.

The OpenAI edit endpoint is a tool for creating and editing text-based content. It provides you with powerful AI capabilities for transforming your content into a more engaging, personalized experience for your readers.

The OpenAI image endpoint is an AI-powered tool that helps you extract, analyze and generate images. It can be used to create automated image classifiers, identify objects in photos, and create digital artwork.

The OpenAI image endpoint is an AI-powered tool that helps you extract, analyze and generate images. It can be used to create automated image classifiers, identify objects in photos, and create digital artwork.

The OpenAI moderation endpoint is a tool for automatically detecting, analyzing, and moderating potentially offensive content. It can help you protect user-generated content on your website.When a form is submitted in WS Form the moderation action can be used to mark a submission as spam if obscene language, hate speech, and other inappropriate content is detected.

Note: The demos above are capped to a predetermined number of requests per day and maximum number of tokens per request. If a demo does not return an expected result, please try again later.

Installation

The OpenAI plugin is installed in the same way as installing the WS Form PRO plugin.

Once installed you will need to activate the license for the plugin. When you purchase the OpenAI plugin, you will be given a license key. If you have lost your license key(s), click here.

To activate your license key:

  1. Click ‘WS Form’ in the WordPress administration menu.
  2. Click ‘Settings’.
  3. Click the ‘OpenAI’ tab at the top of the page.
  4. Enter your license key.
  5. Click the ‘Activate’ button.

If your license key fails to activate, please ensure you are using the correct license key and not your WS Form PRO license key.

Create an OpenAI Account

  1. Visit the OpenAI homepage and click on ‘Sign Up’ in the top right corner.
  2. Fill out the form with your information accept the terms and conditions and click ‘Submit’.
  3. Verify your email address by clicking on the link sent to your inbox.
  4. Log in to your new OpenAI account using the credentials you set up during the sign up process.
  5. Create an API key on the OpenAI API Keys page.

You are now ready to connect WS Form to OpenAI.

Connect WS Form to OpenAI

Connecting WS Form to OpenAI is easy!

  1. Click ‘WS Form’ in the WordPress administration menu.
  2. Click ‘Settings’.
  3. Click the ‘OpenAI’ tab at the top of the page.
  4. Enter your OpenAI API key. You can find this on the OpenAI API Keys page.
  5. Optionally enter your OpenAI organization ID.

Create a Form for OpenAI

Automatically

WS Form can create a form for an OpenAI endpoint in a single click. This process not only creates a form but also fully configures WS Form so that the form is ready to use immediately.

To create a OpenAI form in WS Form:

  1. Click ‘WS Form’ in the WordPress administration menu.
  2. Click ‘Add New’.WS Form PRO - OpenAI Integration - Add New Template
  3. Select the ‘OpenAI’ tab at the top of the page.
  4. Click on an OpenAI template to create a form.
  5. Wait a few moments while the form is created.

That’s it! Your form will be created and is ready to add to your website.

Manually

It is also possible to use any form created in WS Form and add an action so that you can make OpenAI requests.

Add an OpenAI Action

  1. When editing your form, click the ‘Actions’ icon at the top of the page. The ‘Actions’ sidebar will open on the right-hand side of the page.
  2. Click the ‘Add’  icon to add a new action.
  3. Select ‘Make OpenAI Request’ from the Action pulldown.
  4. Click ‘Save & Close’.

You will noticed that the ‘When Should This Action Run?’ setting has neither checkbox checked. This is because we recommend using conditional logic to run the OpenAI action when a custom button is clicked. This ensures the OpenAI requests run without submitting the form and keep the user on the form while they interact with it.

Add Conditional Logic to Run the OpenAI Action

  1. Add a custom button to your form.
  2. Click the ‘Conditional Logic icon at the top of the layout editor.
  3. Create an IF condition that checks if the custom button has been clicked.
  4. Create a THEN statement and choose the ‘Make OpenAI Request’ action, then choose ‘Run Immediately’.
  5. Click ‘Save & Close’.

The ‘Make OpenAI Request’ action will now run when the custom button is clicked.

The OpenAI action settings depend on the endpoint selected.

Completion

The OpenAI Completion endpoint is an AI-powered search engine that uses natural language processing to help you find the answers you need. It can return a list of possible answers, including relevant webpages, articles, and other sources of information, so you can find what you’re looking for quickly and easily.

The completion action settings are as follows:

OpenAI Model

Choose the OpenAI model you want to use for this action.

An OpenAI Model is a pre-trained machine learning model that can be used for a variety of tasks such as natural language processing, image recognition, and more. OpenAI models can be used to build applications that are intelligent and able to learn from their data.

Learn more about OpenAI models.

Input Type

There are two ways of obtaining input for OpenAI:

  • Field
  • Mask
Field

If you choose the ‘Field’ type, you simply choose a field on your form to use for the OpenAI input. You can choose any text based field such as a Text or Text Area field.

Mask

If you choose the ‘Mask’ method you can create an input mask for OpenAI and use WS Form variables to dynamically insert field variables. See ‘Input Mask’ below.

Input Field

Choose the field to use for the input (prompt). This will typically be a text area field on your form.

Input Mask

Use the input mask to create a custom prompt for OpenAI and use WS Form variables to dynamically insert field variables. This is particularly useful if you are developing prompt engineering for OpenAI.

The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article wsform.com/knowledgebase

Customer: #field(123)
Agent:

In the above example mask, the pre-amble provides OpenAI with context about the prompt. We then insert the customers question from field ID 123 into that prompt.

To learn more:

Output Field

Choose the field to use for the output (completion). This will typically be a text area field on your form. The output field can also be configured as the same field as your input field. An example of this can be found in the ‘Completion – Chat’ template where input and output are both contained within the same text area field.

Trim Output

If checked, the completion will be trimmed.

Apply WPAutoP to Output

wpautop is a WordPress function that automatically adds paragraph and line break tags to the text content of a post or page, to properly format the text and make it easy to read on the website.

If checked, WS Form will apply wpautop to the output from OpenAI so that it can be used in fields such as HTML and Text Editor field types.

Use Output Mask

If checked, an ‘Output Mask’ field will appear allowing you to finely control the output that is injected into the ‘Output Field’. You can use WS Form variables in the mask. Use #output to inject the OpenAI output anywhere in the mask.

Append Output

If checked, the OpenAI output will be appended to the existing content in the output field.

Max Tokens

Choose the maximum number of tokens you want to allow each time the action runs. This defaults to 150.

The GPT family of models process text using tokens, which are common sequences of characters found in text. The models understand the statistical relationships between these tokens, and excel at producing the next token in a sequence of tokens.

Learn more about OpenAI tokens.

Inject Start Text

This setting injects text to the beginning of the output prior to it being added to the output field. This setting is included in case you want to simulate output similar to that provided by the API playground.

Inject Restart Text

This setting injects text at the end of the output prior to it being added to the output field.This setting is included in case you want to simulate output similar to that provided by the API playground.

Echo

If checked, the output will include the original input.

Stop Sequences

OpenAI Stop Sequences are used to determine when OpenAI models should stop generating responses. The stop sequence is a predetermined set of words or characters that, when encountered, will indicate to the model that it has reached the end of its output and should not generate any more data. Up to 4 stop sequences can be configured.

Temperature

Choose the temperature setting for the OpenAI request.

The OpenAI Temperature setting is used to adjust how much of a random element is introduced into the output generated by the OpenAI model. A lower completion temperature indicates that the model should be more conservative in its output, while a higher temperature indicates that the model should be more creative with its output.

Top P

Choose the top p setting for the OpenAI request.

The OpenAI Completion Top P setting is used to adjust the probability of which tokens will be included in the generated output. A higher top p value indicates that the model should prioritize tokens with a higher probability, while a lower top p value indicates that the model should consider tokens with lower probabilities.

Frequency Penalty

Choose the frequency penalty setting for the OpenAI request.

The OpenAI Frequency Penalty setting is used to adjust how much frequency of tokens in the source material will influence the output of the model. A higher frequency penalty indicates that the model should favor tokens with a higher frequency, while a lower frequency penalty indicates that the model should prioritize tokens with a lower frequency.

Presence Penalty

Choose the presence penalty setting for the OpenAI request.

The OpenAI Presence Penalty setting is used to adjust how much presence of tokens in the source material will influence the output of the model. A higher presence penalty indicates that the model should favor tokens with a higher presence, while a lower presence penalty indicates that the model should prioritize tokens with a lower presence.

User

An optional unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse, e.g. #user_id.

API Request Timeout (Seconds)

The maximum permissible time in seconds that the API request will run for. Longer timeouts may be required for longer or more complex OpenAI requests.

Edit

The OpenAI edit endpoint is a tool for creating and editing text-based content. It provides you with powerful AI capabilities for transforming your content into a more engaging, personalized experience for your readers.

The edit action settings are as follows:

OpenAI Model

Choose the OpenAI model you want to use for this action.

An OpenAI Model is a pre-trained machine learning model that can be used for a variety of tasks such as natural language processing, image recognition, and more. OpenAI models can be used to build applications that are intelligent and able to learn from their data.

Learn more about OpenAI models.

Input Type

There are two ways of obtaining input for OpenAI:

  • Field
  • Mask
Field

If you choose the ‘Field’ type, you simply choose a field on your form to use for the OpenAI input. You can choose any text based field such as a Text or Text Area field.

Mask

If you choose the ‘Mask’ method you can create an input mask for OpenAI and use WS Form variables to dynamically insert field variables. See ‘Input Mask’ below.

Input Field

Choose the field to use for the input (prompt). This will typically be a text area field on your form.

Input Mask

Use the input mask to create a custom prompt for OpenAI and use WS Form variables to dynamically insert field variables. This is particularly useful if you are developing prompt engineering for OpenAI.

The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article wsform.com/knowledgebase

Customer: #field(123)
Agent:

In the above example mask, the pre-amble provides OpenAI with context about the prompt. We then insert the customers question from field ID 123 into that prompt.

To learn more:

Instruction Field

Choose the field to use for the instruction. This will typically be a text area field on your form.

Output Field

Choose the field to use for the output (completion). This will typically be a text area field on your form. The output field can also be configured as the same field as your input field. An example of this can be found in the ‘Completion – Chat’ template where input and output are both contained within the same text area field.

Trim Output

If checked, the completion will be trimmed.

Apply WPAutoP to Output

wpautop is a WordPress function that automatically adds paragraph and line break tags to the text content of a post or page, to properly format the text and make it easy to read on the website.

If checked, WS Form will apply wpautop to the output from OpenAI so that it can be used in fields such as HTML and Text Editor field types.

Use Output Mask

If checked, an ‘Output Mask’ field will appear allowing you to finely control the output that is injected into the ‘Output Field’. You can use WS Form variables in the mask. Use #output to inject the OpenAI output anywhere in the mask.

Append Output

If checked, the OpenAI output will be appended to the existing content in the output field.

Inject Start Text

This setting injects text to the beginning of the output prior to it being added to the output field. This setting is included in case you want to simulate output similar to that provided by the API playground.

Inject Restart Text

This setting injects text at the end of the output prior to it being added to the output field.This setting is included in case you want to simulate output similar to that provided by the API playground.

Temperature

Choose the temperature setting for the OpenAI request.

The OpenAI Temperature setting is used to adjust how much of a random element is introduced into the output generated by the OpenAI model. A lower completion temperature indicates that the model should be more conservative in its output, while a higher temperature indicates that the model should be more creative with its output.

Top P

Choose the top p setting for the OpenAI request.

The OpenAI Completion Top P setting is used to adjust the probability of which tokens will be included in the generated output. A higher top p value indicates that the model should prioritize tokens with a higher probability, while a lower top p value indicates that the model should consider tokens with lower probabilities.

API Request Timeout (Seconds)

The maximum permissible time in seconds that the API request will run for. Longer timeouts may be required for longer or more complex OpenAI requests.

Moderation

The OpenAI moderation endpoint is a tool for automatically detecting, analyzing, and moderating potentially offensive content. It can help you protect user-generated content on your website.When a form is submitted in WS Form the moderation action can be used to mark a submission as spam if obscene language, hate speech, and other inappropriate content is detected.

The moderation action settings are as follows:

OpenAI Model

Choose the OpenAI model you want to use for this action.

An OpenAI Model is a pre-trained machine learning model that can be used for a variety of tasks such as natural language processing, image recognition, and more. OpenAI models can be used to build applications that are intelligent and able to learn from their data.

Learn more about OpenAI models.

Input Field

Choose the field to use for the input (prompt). This will typically be a text area field on your form.

API Request Timeout (Seconds)

The maximum permissible time in seconds that the API request will run for. Longer timeouts may be required for longer or more complex OpenAI requests.

Image

The OpenAI image endpoint is an AI-powered tool that helps you extract, analyze and generate images. It can be used to create automated image classifiers, identify objects in photos, and create digital artwork.

The image action settings are as follows:

Input Field

Choose the field to use for the input (prompt). This will typically be a text area field on your form.

Output Field

Choose the field to use for the output (completion). There are two options for handling the output:

  1. Use a file field configured as a DropzoneJS type to load the resulting images into.
  2. Use a text or URL field to store the resulting URL from OpenAI.

Number

Choose the number of images to create (max 10).

User

An optional unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse, e.g. #user_id.

API Request Timeout (Seconds)

The maximum permissible time in seconds that the API request will run for. Longer timeouts may be required for longer or more complex OpenAI requests.

Variables

The OpenAI add-on introduces the following variable that can be used in actions:

Name / VariableAdditional Information
Output
#openai_output
Returns the output from OpenAI.