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: {
document: { enabled: true },
urls: { enabled: false },
files: { enabled: true },
sources: [
{
id: 'my-docs',
label: 'My Documents',
getResources: ( query?: string ) => fetchMyDocuments( query ),
getData: ( id ) => fetchDocumentContent( id )
}
],
searchInputVisibleFrom: 5
}
}
}
} )
.then( ... )
.catch( ... );
The document, urls, and files properties control the built-in options in the context menu. Each option can be enabled or disabled using the enabled boolean property.
The sources property is an array where each element represents a custom option in the context menu. When a user clicks on a custom source option, it will display a list of available resources returned by the getResources callback. If a resource doesn't have content provided in the getResources response, the content will be retrieved using the getData callback when the resource is selected. If the list of resources is long enough, the search input will be shown to filter the resources. The minimal number of resources required to show the search input can be configured using searchInputVisibleFrom option.
See AIContextProvider and AIContextResource.
Properties
document : object | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#documentfiles : object | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#filessearchInputVisibleFrom : 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#sourcesurls : object | undefinedmodule:ai/aichat/model/aichatcontext~AIChatContextConfig#urls