Sign up (with export icon)

AIContextProvider

Api-typedef icon typedef

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 )
}
Copy code

Properties

  • getData : ( id: string ) => Promise<string> | undefined

  • getResources : ( query: string ) => Promise<Array<AIContextResource>>

  • icon : string | undefined

  • id : string

  • label : string

  • useDefaultFiltering : boolean | undefined