AIChatContextConfig
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( ... );
The
document,urls, andfilesproperties configure the built-in options in the context menu. Each option can be enabled or disabled using theenabledboolean property. See their respective documentation for more details.The
sourcesproperty 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 thesearchInputVisibleFromoption. SeeAIContextProviderandAIContextResourceto learn more.
Properties
document : object | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#documentWhen 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.files : object | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#filesWhen 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.").
searchInputVisibleFrom : number | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#searchInputVisibleFromThe minimum number of resources to show the search input.
sources : Array<AIContextProvider> | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#sourcesThe configuration of the custom options in the context menu.
Each configured
AIContextProviderrepresents a single menu option that, when clicked, displays a list of available resources that can be attached to the AI prompt.urls : object | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#urlsWhen 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