Skip to content

Commit 6261979

Browse files
committed
update docs
1 parent f89f1dc commit 6261979

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

docs/content/docs/features/ai/backend-integration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const model = createOpenAICompatible({
7070
})('model-id');
7171

7272
// ...
73-
createAIExtension({
73+
AIExtension({
7474
transport: new ClientSideTransport({
7575
model,
7676
}),

docs/content/docs/features/ai/getting-started.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { createBlockNoteEditor } from "@blocknote/core";
2525
import { BlockNoteAIExtension } from "@blocknote/xl-ai";
2626
import { en } from "@blocknote/core/locales";
2727
import { en as aiEn } from "@blocknote/xl-ai/locales";
28-
import { createAIExtension } from "@blocknote/xl-ai";
28+
import { AIExtension } from "@blocknote/xl-ai";
2929
import "@blocknote/xl-ai/style.css"; // add the AI stylesheet
3030

3131
const editor = createBlockNoteEditor({
@@ -34,7 +34,7 @@ const editor = createBlockNoteEditor({
3434
ai: aiEn, // add default translations for the AI extension
3535
},
3636
extensions: [
37-
createAIExtension({
37+
AIExtension({
3838
transport: new DefaultChatTransport({
3939
api: `/api/chat`,
4040
}),
@@ -44,7 +44,7 @@ const editor = createBlockNoteEditor({
4444
});
4545
```
4646

47-
See the [API Reference](/docs/features/ai/reference) for more information on the `createAIExtension` method.
47+
See the [API Reference](/docs/features/ai/reference) for more information on the `AIExtension` options.
4848

4949
## Adding AI UI elements
5050

docs/content/docs/features/ai/reference.mdx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ description: Reference documentation for the BlockNote AI extension
44
imageTitle: 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

1819
type 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
133136
type InvokeAIOptions = {

0 commit comments

Comments
 (0)