@@ -4,16 +4,17 @@ description: Reference documentation for the BlockNote AI extension
44imageTitle : BlockNote AI
55---
66
7- ## ` createAIExtension `
7+ ## ` AIExtension `
88
9- Use ` createAIExtension ` to create a new AI Extension that can be registered to an editor when calling ` useCreateBlockNote ` .
9+ Use ` AIExtension ` to create a new AI Extension that can be registered to an editor when calling ` useCreateBlockNote ` .
1010
1111``` typescript
1212// Usage:
13- const aiExtension = createAIExtension (opts : AIExtensionOptions );
14-
15- // Definitions:
16- function createAIExtension(options : AIExtensionOptions ): (editor : BlockNoteEditor ) => AIExtension ;
13+ useCreateBlockNote ({
14+ // Register the AI extension
15+ extensions: [AIExtension (options )],
16+ // other editor options
17+ });
1718
1819type AIExtensionOptions = AIRequestHelpers & {
1920 /**
@@ -42,7 +43,7 @@ type AIRequestHelpers = {
4243 * Customize which stream tools are available to the LLM.
4344 */
4445 streamToolsProvider? : StreamToolsProvider <any , any >;
45- // Provide `streamToolsProvider` in createAIExtension (options) or override per call via InvokeAIOptions.
46+ // Provide `streamToolsProvider` in AIExtension (options) or override per call via InvokeAIOptions.
4647 // If omitted, defaults to using `aiDocumentFormats.html.getStreamToolsProvider()`.
4748
4849 /**
@@ -59,12 +60,12 @@ type AIRequestHelpers = {
5960};
6061```
6162
62- ## ` AIExtension `
63+ ## ` AIExtension ` extension instance
6364
64- The ` AIExtension ` class is the main class for the AI extension. It exposes state and methods to interact with BlockNote's AI features.
65+ The ` AIExtension ` extension instance returned by ` editor.getExtension(AIExtension) ` exposes state and methods to interact with BlockNote's AI features.
6566
6667``` typescript
67- class AIExtension {
68+ type AIExtensionInstance = {
6869 /**
6970 * Execute a call to an LLM and apply the result to the editor
7071 */
@@ -113,6 +114,8 @@ class AIExtension {
113114 rejectChanges(): void ;
114115 /** Retry the previous LLM call (only valid when status is "error") */
115116 retry(): Promise <void >;
117+ /** Abort the current LLM request */
118+ abort(reason ? : any ): Promise <void >;
116119 /** Advanced: manually update the status shown by the AI menu */
117120 setAIResponseStatus(
118121 status :
@@ -122,12 +125,12 @@ class AIExtension {
122125 | " user-reviewing"
123126 | { status: " error" ; error: any },
124127 ): void ;
125- }
128+ };
126129```
127130
128131### ` InvokeAI `
129132
130- Requests to an LLM are made by calling ` invokeAI ` on the ` AIExtension ` object . This takes an ` InvokeAIOptions ` object as an argument.
133+ Requests to an LLM are made by calling ` invokeAI ` on the ` AIExtension ` instance . This takes an ` InvokeAIOptions ` object as an argument.
131134
132135``` typescript
133136type InvokeAIOptions = {
0 commit comments