feat: Vercel AI SDK v6 with tool-calling #78
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a Next.js example application of how to use Transformers.js models that support tool-calling with the Vercel AI SDK v6 (I also renamed the old
next-vercel-ai-sdktonext-vercel-ai-sdk-v5).It uses @browser-ai that acts as a Transformers.js model provider for the Vercel AI SDK, enabling seamless tool-call management.
The internals of the provider handles incremental streaming that detects which tool is being called before the model finishes generating arguments, which is like how native cloud-based API's handle tool-call streaming.
It also automatically handles different model tool-call outputs, such as XML tags (
<tool_call>) and Python-style ([functionName(args)]) syntax, which enhances the Developer Experience dramatically. Easily switch between Qwen3, LFM2, Granite models without introducing a bunch of boilerplate code.On the UI side, it also allows for HITL (human in the loop) tool-calls by just setting a simple
needsApprovalflag in the tool-call schema.@xenova let me know if anything needs to be changed :)
Demo:
demooo.mp4