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.
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 )
}
]
}
}
}
} )
.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.
See AIContextProvider
and
AIContextResource
.
Properties
-
document : object | undefined
module:ai/aichat/model/aichatcontext~AIChatContextConfig#document
-
files : object | undefined
module:ai/aichat/model/aichatcontext~AIChatContextConfig#files
-
sources : Array<AIContextProvider> | undefined
module:ai/aichat/model/aichatcontext~AIChatContextConfig#sources
-
urls : object | undefined
module:ai/aichat/model/aichatcontext~AIChatContextConfig#urls