Skip to content
1 min read · 125 words

Type Alias: MediaOutputExtractorFn ​

ts
type MediaOutputExtractorFn = (
  result: unknown,
) => GeneratedMediaOutput[] | Promise<GeneratedMediaOutput[]>;

Defined in: src/batteries/llm/chat_common/types.ts:326

Extracts generated media from a battery's raw generation result so the adapter can surface it as assistant Message.attachments. Injectable + defaulted to absent (no media output) on every LLM battery, mirroring the toolCallParser / reasoningParser / decodeMedia injection seams.

Parameters ​

ParameterType
resultunknown

Returns ​

| GeneratedMediaOutput[] | Promise<GeneratedMediaOutput[]>

Remarks ​

result is the battery-native generation object (transformers.js model.generate / pipeline output; the LiteRT-LM final Message + raw content items) — deliberately typed unknown because its shape is battery-specific and the extractor is supplied by whoever wraps a media-emitting model. Returning an empty array (or not supplying the hook) yields today's text-only behavior, byte-for-byte unchanged.