-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Stabilized message.id during streamText call with multiple steps #6267
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
Open
crazyjncsu
wants to merge
173
commits into
vercel:main
Choose a base branch
from
crazyjncsu:stability-stream-text-message-id
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Stabilized message.id during streamText call with multiple steps #6267
crazyjncsu
wants to merge
173
commits into
vercel:main
from
crazyjncsu:stability-stream-text-message-id
Conversation
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
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…nge (vercel#5531) Co-authored-by: Carl Brugger <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…#5541) Co-authored-by: Bram Meerten <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
) Co-authored-by: Sam Denty <[email protected]> Co-authored-by: Sam Denty <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…global (vercel#6045) ## Background As brought up in vercel#4908 (comment), react-native doesn't have the FileList global ## Summary Conditionally check for it
…ent (vercel#6047) <!-- Welcome to contributing to AI SDK! We're excited to see your changes. We suggest you read the following contributing guide we've created before submitting: https://github.com/vercel/ai/blob/main/CONTRIBUTING.md --> ## Background Splits up vercel#5972 into package changes and updates to examples. ## Summary Moves capabilities validation downstream to the request level instead of the method level. This PR adds a new private `assertCapability` method called at the request level. This means our custom, lightweight client defaults strict mode to true for tool listing and tool calling. ## Verification <!-- For features & bugfixes. Please explain how you *manually* verified that the change works end-to-end as expected (independent of automated tests). Remove the section if it's not needed (e.g. for docs). --> ## Tasks <!-- This task list is intended to help you keep track of what you need to do. Feel free to add tasks and remove unnecessary tasks as needed. Please check if the PR fulfills the following requirements: --> - [x] Tests have been added / updated (for bug fixes / features) - [ ] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) ## Future Work <!-- Feel free to mention things not covered by this PR that can be done in future PRs. Remove the section if it's not needed. --> ## Related Issues <!-- List related issues here, e.g. "Fixes vercel#1234". Remove the section if it's not needed. -->
…mable HTTP transport usage (vercel#5972) ## Background The current experimental MCP client already supports the new HTTP transport through the custom transport option (over passing in a config). ## Summary Updates documentation to illustrate usage of the new Streamable HTTP Transport with `experimental_createMCPClient` for tool conversion. As of now, `experimental_createMCPClient` is only used in the AI SDK as a way to fetch and call MCP server tools; for this reason, we are **not** adding support for Session Management or Resumable Streams - which are new features supported by the new HTTP transport. Examples have been updated to illustrate basic usage, and a new Next.js example has been added to illustrate setting up a **stateless** MCP **server** to be used with `useChat` and `streamText`. ## Tasks <!-- This task list is intended to help you keep track of what you need to do. Feel free to add tasks and remove unnecessary tasks as needed. Please check if the PR fulfills the following requirements: --> - [x] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) - [ ] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) ## Future Work Given the deprecation of the SSE transport, we should likely deprecate on our end as well. We should consider fully deprecating native support for transports (e.g. our custom `stdio` transport), and enforcing users to always pass in a custom transport to limit need for maintenance on our end. ## Related Issues Fixes vercel#5984
## Background It seems like publishing the TypeScript files isn't intended. ## Summary Only publish the bundled files for `ai/mcp-stdio`/ ## Verification `npm pack` now doesn't contain TypeScript files anymore: ``` ... npm notice 585.0kB dist/index.mjs.map npm notice 6.7kB mcp-stdio/dist/index.d.mts npm notice 6.7kB mcp-stdio/dist/index.d.ts npm notice 11.1kB mcp-stdio/dist/index.js npm notice 21.6kB mcp-stdio/dist/index.js.map npm notice 9.3kB mcp-stdio/dist/index.mjs npm notice 21.5kB mcp-stdio/dist/index.mjs.map npm notice 3.6kB package.json ... ``` Co-authored-by: Sam Denty <[email protected]>
## Background Recently [Weave](https://github.com/wandb/weave) by Weights and Biases added OTEL support and some specialized parsing for Vercel's span attributes. This PR provides docs for configuring exports to Weave and adds it to the list of observability providers. ## Summary Added setup and configuration docs for exporting OTEL traces from the AI SDK to Weave projects
## Background This resolves an issue a user ran into: vercel#6041 ## Summary Aligned openai provider with openai-compatible
## Background This pull request adds the ability for clients to resume an ongoing chat generation stream after a network disconnect. ## Summary This pull request adds support for the `useChat` hook to resume an ongoing chat generation stream by exposing `experimental_resume()` that can be called by any client, typically during the initial mount of the hook. The `experimental_resume` function makes a `GET` request to the api endpoint you've initialized the hook with (or `/api/chat` by default) and streams the contents of the stream if it is active or fails silently if it has ended. In order for `experimental_resume` to work as intended, it requires the usage of the [`resumable-stream`](https://www.npmjs.com/package/resumable-stream) package for stream creation and a redis instance for the package to manage the pub/sub mechanism. ## Verification An example has been added at `examples/next-openai/app/use-chat-resume` to test the feature. Follow the following steps to test it end-to-end: 1. Run the development server 2. Navigate to `http://localhost:3000/use-chat-resume` 3. Send a message that will have a longer generation duration, example "Write an essay about Michael Jordan" 4. Once the generation starts, click the chat id above to open the conversation in a new tab 5. Verify the stream gets resumed ## Tasks - [x] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added - [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) --------- Co-authored-by: Lars Grammel <[email protected]>
# Releases ## [email protected] ### Patch Changes - Updated dependencies [6c59ae7] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - 6c59ae7: feat (ui/react): support resuming an ongoing stream - Updated dependencies [6c59ae7] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [6c59ae7] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [6c59ae7] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - 6c59ae7: feat (ui/react): support resuming an ongoing stream ## @ai-sdk/[email protected] ### Patch Changes - [email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [6c59ae7] - @ai-sdk/[email protected] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
## Background This pull request fixes a docs formatting issue due to a missing comma in useChat reference docs. ## Summary Fixed formatting in useChat reference docs by adding a comma. ## Tasks - [x] Documentation has been added / updated (for bug fixes / features) - [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) ## Related Issues vercel#6052
## Background The Dify provider allows developers to easily integrate Dify's application workflow with their applications using the Vercel AI SDK. ## Summary This PR adds the Dify provider documentation to the AI SDK, enabling users to understand how to implement and use the Dify integration. ## Tasks - [x] Documentation has been added for the Dify provider - [x] Installation instructions are included - [x] Usage examples for both cloud and self-hosted instances are provided ## Related Issues [Support Dify Provider](vercel#4084) --------- Co-authored-by: Lars Grammel <[email protected]>
<!-- Welcome to contributing to AI SDK! We're excited to see your changes. We suggest you read the following contributing guide we've created before submitting: https://github.com/vercel/ai/blob/main/CONTRIBUTING.md --> ## Background <!-- Why was this change necessary? --> ## Summary <!-- What did you change? --> ## Verification <!-- For features & bugfixes. Please explain how you *manually* verified that the change works end-to-end as expected (independent of automated tests). Remove the section if it's not needed (e.g. for docs). --> ## Tasks <!-- This task list is intended to help you keep track of what you need to do. Feel free to add tasks and remove unnecessary tasks as needed. Please check if the PR fulfills the following requirements: --> - [ ] Tests have been added / updated (for bug fixes / features) - [ ] Documentation has been added / updated (for bug fixes / features) - [ ] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [ ] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) ## Future Work <!-- Feel free to mention things not covered by this PR that can be done in future PRs. Remove the section if it's not needed. --> ## Related Issues <!-- List related issues here, e.g. "Fixes vercel#1234". Remove the section if it's not needed. -->
## Background The safetyRating was an empty object for some reason ## Summary Fixes vercel#6109
…el#6133) ## Background Before in issues like vercel#5499 & vercel#5833, if users ran into an issue where the messages array failed to parse correctly they'd run into a difficult to debug error `Invalid prompt: messages must be an array of CoreMessage or UIMessage` ## Summary This PR extends these error messages to include more details on what exactly went wrong, which is useful information for debugging when stuff breaks. On security: I think this is an okay change since the data sent is not private
This adds gemini-2.5-pro-preview-05-06 to AI SDK
## Background Laminar has updated its SDK and docs and added an example Next.js app. This is needed to better guide AI SDK users ## Summary A guide on Laminar as an observability provider is updated.
## Background The below MCP SSE message will make the stream reader timeout. ``` data: /message?sessionId=123\r\nevent: endpoint ``` ## Summary Fix the `splitLines` parser issue. The CRLF pointer was incorrectly implemented.
# Releases ## [email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - d87b9d1: fix(provider-utils): fix SSE parser bug (CRLF) ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - [email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] ## @ai-sdk/[email protected] ### Patch Changes - Updated dependencies [d87b9d1] - @ai-sdk/[email protected] - @ai-sdk/[email protected] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ming stream (vercel#6224) ## Background This pull request updates the documentation for the GET handler in the resumable streams section to account for a race condition that may occur when the stream ends in-flight. ## Summary Updated the route by adding the code snippet that handles the above condition. ## Tasks - [x] Documentation has been added / updated (for bug fixes / features) - [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) ## Related Issues vercel#6052
## Background Bug with Vue that led to status not updating when tab was changed. ## Summary Changes status from using SWR to using Vue ref.
# Releases ## @ai-sdk/[email protected] ### Patch Changes - b54cb59: fix (ai-sdk/vue): fix status reactivity Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Background
When dealing with chat message persistence, it is certainly helpful if the server and client have similar representations of a message, most importantly the key/identifier/id being the same. The id of a message is a bit of a difficult concept due to the message being an aggregation of activities from an AI model and tool executions where each component has an id.
In vercel ai, the server message id comes from the first step part, but the client message id comes from the last step part. The messages on the client get their ids in processChatResponse, on the server in appendResponseMessages. The server chooses the id from the first message part. The client seems to attempt to do this, but fails because the logic doesn't fail to prevent the id from being overridden.
#4845
Summary
I fixed the client processChatResponse to keep the message id from the first step part even as more step parts come in.
Verification
I tested with a variety of ai multi-step responses.
Tasks
pnpm changeset
in the project root)pnpm prettier-fix
in the project root)Future Work
Related Issues