Skip to content
1 min read · 190 words

Function: renderMediaToLiteRtContent()

ts
function renderMediaToLiteRtContent(input: {
  media: Media;
  modalityEnabled: boolean;
  nonce: string;
  renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
  renderUntrustedContent: (
    content: string,
    attrs: UntrustedContentAttrs,
  ) => string;
  unsupportedMediaPolicy: UnsupportedMediaPolicy;
  warn?: (msg: string) => void;
}): Promise<MessageContentItem[]>;

Defined in: src/batteries/llm/litert_lm/helpers.ts:208

Render a media kind/mime/filename into a LiteRT content item, or fall back per unsupportedMediaPolicy.

Parameters

ParameterType
input{ media: Media; modalityEnabled: boolean; nonce: string; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }
input.mediaMedia
input.modalityEnabledboolean
input.noncestring
input.renderTrustedContent(content: string, attrs: TrustedContentAttrs) => string
input.renderUntrustedContent(content: string, attrs: UntrustedContentAttrs) => string
input.unsupportedMediaPolicyUnsupportedMediaPolicy
input.warn?(msg: string) => void

Returns

Promise<MessageContentItem[]>

Remarks

The preview .litertlm models are text-in/text-out, and the exact multimodal content-item wire shape is not yet stable in the published types. This maps image/audio/document/video to a best-effort { type, path }-style item when the matching modality flag is enabled, and otherwise degrades through the shared unsupportedMediaPolicy (stash text / synthetic description / throw). Verify the content-item shape against the installed .d.ts + a real multimodal model before relying on the native path.