-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(ai): add convertDataPart option to convertToModelMessages #9720
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
feat(ai): add convertDataPart option to convertToModelMessages #9720
Conversation
Add optional convertDataPart callback for converting custom data parts (URLs, code files, etc.) to text or file parts that models can process. Fully type-safe using existing UIMessage generics.
| }); | ||
| ``` | ||
|
|
||
| **Including Code Files as Context** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this, thanks for putting this together @Drew-Garratt 👏
Would it be worth to include an example here for toggling on custom tools that a user might turn on when sending the user message? In this way, it can be stored alongside the other user message parts inside the DB and one can easily restore this context when the user wants to edit the message later on.
|
Thanks for the PR! i like where it is headed but some details need to be changed. I'll see if I can make the changes today on this branch. |
|
Changed the generics, simplified the tests, changed return from null to undefined, exposed is* helpers again, supported assistant data parts. |
content/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx
Outdated
Show resolved
Hide resolved
content/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx
Outdated
Show resolved
Hide resolved
…sages.mdx Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
|
|
Summary
Adds optional
convertDataPartcallback toconvertToModelMessagesfor converting custom data parts (URLs, code files, etc.) into text or file parts that models can process.Changes
convertDataPartoption toconvertToModelMessagesfunctionisTextUIPartandisFileUIParttoui-messages.tsTesting
convert-to-model-messages.test.tsDocumentation
Related Issues
Closes #9617