NEWCKEditor AI is here! Register for our AI in Enterprise webinar.
Sign up (with export icon)

AIChatContextConfig

Api-typedef icontypedef

The configuration of the AI Chat menu for adding resources to the prompt context.

This menu allows users to attach additional resources (files, documents, URLs) to their AI chat prompts, providing the AI with more context for generating responses. The properties defined in this config are set in the config.ai.chat.context namespace.

It also allows to change the minimal number of items in the context adding menu required to show the search input using config.ai.chat.context.searchInputVisibleFrom option.

ClassicEditor
	.create( editorElement, {
		ai: {
			chat: {
				context: {
					// Allow for adding the current document content to the conversation context.
					document: { enabled: true },

					// Allow for adding URLs (web pages, blogs, etc.) to the conversation context.
					urls: { enabled: false },

					// Allow for uploading files (PDF, Word, etc.) to the conversation context.
					files: { enabled: true },

					// Configuration of external resources (files, text, etc.) to the conversation context.
					sources: [
						{
							id: 'my-docs',
							label: 'My Documents',
							getResources: ( query ) => fetchMyDocuments( query ),
							getData: ( id ) => fetchDocumentContent( id )
						}
					],

					// The minimum number of resources to show the search input.
					searchInputVisibleFrom: 5
				}
			}
		}
	} )
	.then( ... )
	.catch( ... );
Copy code
  • The document, urls, and files properties configure the built-in options in the context menu. Each option can be enabled or disabled using the enabled boolean property. See their respective documentation for more details.

  • The sources property introduces customizable menus to the conversation context user interface that display a list of external resources that can be attached to the AI prompt. The user can search resources and the minimal number of resources required to show the search input can be configured using the searchInputVisibleFrom option. See AIContextProvider and AIContextResource to learn more.

Properties

  • Chevron-right icon

    document : object | undefined

    When this option is enabled (default), adding the editor document to the context of the conversation becomes possible. This allows the AI to interact with the content of the entire document if the user asks for it (e.g. "Write an introduction to the document." or "Shorten headings to make them more concise.").

    Note: When set true, the document content will be automatically added to the context of the new conversation. The user can still remove it using the user interface before sending the message if needed.

    Note: When set to false, the AI Quick Actions that use AI Chat will be disabled and removed from the UI. The selection can’t be sent to AI Chat without sending the entire document.

  • Chevron-right icon

    files : object | undefined

    When this option is enabled (default), adding files to the context of the conversation becomes possible. This allows the AI to interact with the content of the files (e.g. Word documents, PDF files, etc.) if the user adds them to the context (e.g. "Write a very brief summary of the attached Word document.").

  • Chevron-right icon

    searchInputVisibleFrom : number | undefined

    The minimum number of resources to show the search input.

  • Chevron-right icon

    sources : Array<AIContextProvider> | undefined

    The configuration of the custom options in the context menu.

    Each configured AIContextProvider represents a single menu option that, when clicked, displays a list of available resources that can be attached to the AI prompt.

    Learn more about the configuration of custom resources.

  • Chevron-right icon

    urls : object | undefined

    When this option is enabled (default), adding URLs to the context of the conversation becomes possible. This allows the AI to interact with the content of the URLs (e.g. web pages, blog posts, etc.) if the user adds them to the context (e.g. "Write a very brief summary of the linked blog post.").

Value

object