Skip to content

Commit 6dba7fe

Browse files
committed
fixes
1 parent ff572fb commit 6dba7fe

File tree

18 files changed

+44
-69
lines changed

18 files changed

+44
-69
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# AI Integration with server LLM execution + promptbuilder
1+
# AI Integration with server LLM message persistence
22

33
This example shows how to setup to add AI integration while handling the LLM calls (in this case, using the Vercel AI SDK) on your server, using a custom executor.
44

5-
Prompt building is done on the server as well
5+
Instead of sending all messages, these are kept server-side and we only submit the latest message.

examples/09-ai/07-server-promptbuilder/src/App.tsx renamed to examples/09-ai/07-server-persistence/src/App.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import {
1212
useCreateBlockNote,
1313
} from "@blocknote/react";
1414
import {
15-
aiDocumentFormats,
1615
AIMenuController,
1716
AIToolbarButton,
1817
createAIExtension,
19-
defaultAIRequestSender,
2018
getAISlashMenuItems,
2119
} from "@blocknote/xl-ai";
2220
import { en as aiEn } from "@blocknote/xl-ai/locales";
@@ -41,7 +39,7 @@ export default function App() {
4139
// we adjust the transport to not send all messages to the backend
4240
transport: new DefaultChatTransport({
4341
// (see packages/xl-ai-server/src/routes/vercelAiSdkPersistence.ts)
44-
api: `${BASE_URL}/server-promptbuilder/streamText`,
42+
api: `${BASE_URL}/server-persistence/streamText`,
4543
prepareSendMessagesRequest({ id, body, messages, requestMetadata }) {
4644
// we don't send the messages, just the information we need to compose / append messages server-side:
4745
// - the conversation id
@@ -65,19 +63,12 @@ export default function App() {
6563
// should have a server-side generated id to ensure uniqueness
6664
// see https://github.com/vercel/ai/issues/7340#issuecomment-3307559636
6765
id,
68-
// get the promptData from requestMetadata (set by `promptAIRequestSender`) and send to backend
69-
promptData: (requestMetadata as any).promptData,
7066
lastToolParts,
7167
// messages, -> we explicitly don't send the messages array as we compose messages server-side
7268
},
7369
};
7470
},
7571
}),
76-
// customize the aiRequestSender to not update the messages array on the client-side
77-
aiRequestSender: defaultAIRequestSender(
78-
async () => {}, // disable the client-side promptbuilder
79-
aiDocumentFormats.html.defaultPromptInputDataBuilder,
80-
),
8172
}),
8273
],
8374
// We set some initial content for demo purposes

packages/xl-ai-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@ai-sdk/openai-compatible": "^1.0.22",
5252
"@blocknote/xl-ai": "workspace:*",
5353
"@hono/node-server": "^1.19.5",
54-
"ai": "^5.0.76",
54+
"ai": "^5.0.102",
5555
"hono": "^4.10.0"
5656
},
5757
"devDependencies": {

0 commit comments

Comments
 (0)