AIContextProvider
The configuration of a custom option in the AI Chat menu for adding resources to the prompt context.
Each AIContextProvider represents a single menu option that, when clicked, displays a list of available
resources that can be attached to the AI prompt. The label is displayed as the menu option text, and the
optional icon can be used to provide a visual representation.
The getResources callback is called when the user clicks on the menu option and should return an array of
available resources. If a resource doesn't have content provided in the getResources response (i.e., the data
property is undefined), the content will be retrieved using the getData callback when the resource is selected
to be included in the prompt context.
The optional useDefaultFiltering property controls whether the built-in search filtering should be applied
to the resources returned by getResources. When set to true, the resources will be filtered
based on the user's search query. When set to false, all resources will be displayed regardless of the search query,
allowing the provider to handle filtering internally within the getResources callback.
{
id: 'knowledge-base',
label: 'Knowledge Base',
icon: 'book',
useDefaultFiltering: false,
getResources: async ( query?: string ) => [
{ id: 'doc1', type: AIContextItemType.DOCUMENT, label: 'User Guide' },
{ id: 'doc2', type: AIContextItemType.DOCUMENT, label: 'API Reference', data: 'content...' }
],
getData: async ( id ) => fetchDocumentContent( id )
}
Properties
-
getData : ( id: string ) => Promise<string> | undefinedmodule:ai/aichat/model/aichatcontext~AIContextProvider#getData -
getResources : ( query: string ) => Promise<Array<AIContextResource>>module:ai/aichat/model/aichatcontext~AIContextProvider#getResources -
icon : string | undefinedmodule:ai/aichat/model/aichatcontext~AIContextProvider#icon -
id : stringmodule:ai/aichat/model/aichatcontext~AIContextProvider#id -
label : stringmodule:ai/aichat/model/aichatcontext~AIContextProvider#label -
useDefaultFiltering : boolean | undefinedmodule:ai/aichat/model/aichatcontext~AIContextProvider#useDefaultFiltering