Skip to content

feat: custom AI executors #1903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: feature/call-streamtools-manually
Choose a base branch
from

Conversation

YousefED
Copy link
Collaborator

@YousefED YousefED commented Jul 31, 2025

Instead of the current solution where BlockNote makes direct calls to LLMs from the client using the Vercel AI SDK (or via a proxy), you can now define custom executors and route calls via your own backend.

On your backend, you can then invoke your LLM (potentially adding more context, tools, etc). While a bit more work to set up, this architecture is more inline with the Vercel SDK:

  • clients do a POST request to the backend
  • the backend calls streamObject, generateObject, streamText or generateText
  • the responses are then passed to the client as a "datastream"

I think this will be a significant architectural improvement, but consider this a first draft / RFC

  • Example which calls backend via POST request (source)
  • Example backend implementation (only streamObject and generateObject are implemented for now) (source)

(at this moment the live demo doesn't work yet - it will require a deploy of the server (which is based on main))

TODOs

  • Add support for tool calling + streamText / generateText instead of object generation
  • Add examples to integrate with other backends (e.g.: langchain / openai directly)
  • update docs + tests

To discuss

Messages configurability
The current implementation still composes the messages array on the client (configurable via a PromptBuilder). Of course this can still be modified on the server. Alternatively, we could choose to pass all relevant information from the editor (document, cursor position, etc) to the backend, and compose the messages array there.

Response handling
The current demo (see server code) passes in the schema from BlockNote and directly responses to the client as a datastream. Real-world use-cases might also require mixing with other (app-specific) tools which would change the schema. We'll need some feedback on whether this needs better support in the API. Of course, it's always possible to construct your own schema (input) and datastream (output), but this might not be the ideal DX

Copy link

vercel bot commented Jul 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Aug 4, 2025 7:14am
blocknote-website ✅ Ready (Inspect) Visit Preview Aug 4, 2025 7:14am

Copy link

pkg-pr-new bot commented Aug 4, 2025

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@1903

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@1903

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@1903

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@1903

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@1903

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@1903

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@1903

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@1903

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@1903

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-email-exporter@1903

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@1903

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@1903

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@1903

commit: 75dcf10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant