Skip to content

Conversation

@NoelJacob
Copy link

Currently this is made for my personal use. It's a hook for any transformation when each part of stream is recieved. Also made prepareBody support async functions. Currently only onFilePart is added and only on react.

Would this feature be appreciated? If so I can make a proper PR.

@lgrammel
Copy link
Collaborator

thanks - in ai sdk 5 you can implement your own ChatTransport and transform incoming UIMessageStreamPart streams.

@NoelJacob
Copy link
Author

I saw the blog but any docs for it? Where can learn what functions to use and stuff?

@zhm
Copy link
Contributor

zhm commented May 21, 2025

@NoelJacob I got a custom onPart working in v5 with this custom transport that overrides the default transport.

https://gist.github.com/zhm/ae4ede57ead9712820340e2f1248c21a

A few notes:

  • adds onPart param to the chat store factory
  • UIDataPartSchemas and InferUIDataParts types don't seem to be exported (yet), but I might be missing something
  • Would be far less boilerplate if defaultChatStore() accepted an optional transport
  • Perhaps onPart should just be baked into defaultChatStore with onFinish, seems fairly reasonable

@NoelJacob NoelJacob closed this May 30, 2025
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.

3 participants