Add Vercel AI SDK stream adapter and message format#260
Open
ankit-thesys wants to merge 4 commits intothesysdev:mainfrom
Open
Add Vercel AI SDK stream adapter and message format#260ankit-thesys wants to merge 4 commits intothesysdev:mainfrom
ankit-thesys wants to merge 4 commits intothesysdev:mainfrom
Conversation
- Add vercelAIAdapter (StreamProtocolAdapter) and vercelAIMessageFormat (MessageFormat) to react-headless for Vercel AI SDK compatibility - Add comprehensive test suites for both the adapter and message format - Add vercel-ai-chat example app demonstrating usage with Next.js - Add `ai` SDK as a devDependency in react-headless - Fix RUN_ERROR event to read `message` instead of `error` - Apply lint/format fixes across react-headless and react-ui Made-with: Cursor
|
@ankit-thesys is attempting to deploy a commit to the thesys-devs Team on Vercel. A member of the Team first needs to authorize it. |
…to feature/versel-sdk-adaptor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…to feature/versel-sdk-adaptor
…to feature/versel-sdk-adaptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds first-class support for the Vercel AI SDK in
@openuidev/react-headless, enabling developers to use OpenUI with Vercel'saipackage out of the box.What's included
vercelAIAdapter— a newStreamProtocolAdapterthat parses Vercel AI SDK's UI message stream protocol (data-stream format with0:,2:,9:,a:,e:prefixed lines) and converts them into AG-UI eventsvercelAIMessageFormat— a newMessageFormatimplementation that converts between AG-UIMessage[]and Vercel AI SDK'sModelMessage[], supporting:experimental_attachmentsvercel-ai-chatexample app — a full Next.js example demonstrating both a simple chat page and an agent page with tool use, usingstreamTextfrom the Vercel AI SDK on the server andFullScreen+ the new adapters on the clientvercelAIAdapter(stream parsing, text streaming, tool calls, finish reasons, errors, multi-step) andvercelAIMessageFormat(round-trip conversions, edge cases)Other changes
aiSDK as a devDependency inreact-headless(for type imports only — no runtime dependency)RUN_ERRORevent handler to readevent.messageinstead ofevent.errorreact-headlessandreact-ui(import ordering, formatting)How to test
pnpm installfrom the repo roothttp://localhost:3000for the basic chathttp://localhost:3000/agentfor the agent with tool useTest plan
vercelAIAdapterunit tests pass (text streaming, tool calls, finish events, error handling, multi-step)vercelAIMessageFormatunit tests pass (user/assistant/system messages, tool calls, tool results, attachments, reasoning, round-trip conversions)react-headlesstests still passvercel-ai-chatexample app against a live OpenAI API keyMade with Cursor