Skip to content

Theonlyhamstertoh/v4-to-v5-vercel-ai-message-converter-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vercel-ai-sdk v4 → v5 data migration

Overview

This project helps migrate UI message data from Vercel AI SDK v4 to v5.

Install

pnpm install

Quick start (conversion demo)

Runs the example converter that validates a v4 message and converts it to v5.

pnpm convert

You should see the parsed v4 object followed by the converted v5 object logged to the console.

Using the conversion API in your code

import { convertV4MessageToV5, V5UIMessageSchema } from "./src/schema";

// v4Message: your v4 UI message object
const v5Maybe = convertV4MessageToV5(v4Message);
if (v5Maybe) {
    const v5 = V5UIMessageSchema.parse(v5Maybe); // validate
    // persist or use v5
}

Please customize this to your need, there are areas that I skipped in the file because the fields were deprecated and did not apply to me. I included most use cases and as 1-to-1 as possible but may have forgot some. Hopefully this helps you in some way : )

About

This helps convert your AI SDK V4 messages into V5 from Vercel.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors