convertToModelMessages

Convert UI messages to model messages.

Maps the UIMessage shape a client sends into the Message values a model takes, flattening UI-only parts. This is the first thing a server route does with an incoming chat body.

let messages = convertToModelMessages(body.messages)

Signature

func convertToModelMessages(
    _ uiMessages: [UIMessage]
) -> [Message]

Defined in Sources/AI/Transport/StreamBridge.swift.

Parameters

ParameterTypeDefault
_[UIMessage]required

Returns

A [Message].

See also