Docs
Code Rabbit
Cloudflare
AG Grid
Netlify
Neon
WorkOS
Clerk
Convex
Electric
Sentry
Prisma
Strapi
Unkey
UI.dev
Code Rabbit
Cloudflare
AG Grid
Netlify
Neon
WorkOS
Clerk
Convex
Electric
Sentry
Prisma
Strapi
Unkey
UI.dev
Class References
Function References
Interface References
Type Alias References
Variable References
Function References

modelMessageToUIMessage

Function: modelMessageToUIMessage()

ts
function modelMessageToUIMessage(modelMessage, id?): UIMessage;
function modelMessageToUIMessage(modelMessage, id?): UIMessage;

Defined in: activities/chat/messages.ts:155

Convert a ModelMessage to UIMessage

This conversion creates a parts-based structure:

  • content field → TextPart
  • toolCalls array → ToolCallPart[]
  • role="tool" messages should be converted separately and merged

Parameters

modelMessage

ModelMessage

The ModelMessage to convert

id?

string

Optional ID for the UIMessage (generated if not provided)

Returns

UIMessage

A UIMessage with parts