Skip to content

Latest commit

 

History

History
88 lines (53 loc) · 3.3 KB

File metadata and controls

88 lines (53 loc) · 3.3 KB

AI Assistant plugin

The AI Assistant plugin allows a user to interact with registered AI APIs by sending queries and viewing responses within a {productname} editor dialog.

Once a response is generated and displayed within the dialog, the user can choose to either:

  1. insert it into the editor at the current selection;

  2. create another query to further refine the response generated by the AI; or

  3. close the dialog and discard the returned response.

Users can retrieve a history of their conversations with the AI using the getThreadLog API, including any discarded responses.

Interactive example

Note
This example uses a proxy endpoint to communicate with the OpenAI API. This is done to avoid exposing the API key in the client-side code. For more information on using a proxy server with the AI Assistant plugin, see the AI Proxy Server reference guide.

liveDemo::ai[]

Basic setup

To add the AI Assistant plugin to the editor, follow these steps:

  • Add ai to the plugins option in the editor configuration.

  • Add the ai_request function to the editor configuration.

For example:

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  plugins: 'ai',
  toolbar: 'aidialog aishortcuts',
  ai_request: <AI_REQUEST_FUNCTION>,
});

Using a proxy server with AI Assistant

Note
As per OpenAI’s best practices for API key safety, deployment of an API key in a client-side environment is specifically not recommended.

Using a proxy server obviates this, reducing financial and service uptime risks.

A proxy server can also provide flexibility by allowing extra processing before the request is sent to an LLM AI endpoint and before returning the response to the user.

See the AI Proxy Server reference guide for information on how to setup a proxy server for use with the AI Assistant.

Note
The AI Proxy Server reference guide is, as its name notes, a reference. There is no single proxy server setup that is right or correct for all circumstances and other setups may be better for your use-case.

Commands

The AI Assistant plugin provides the following {productname} commands.

Events

The AI Assistant plugin provides the following events.

APIs

The AI Assistant plugin provides the following APIs.