Skip to main content
Version: Next

mellea.serve.models

User-facing types for m serve.

Classes

CLASS TextContent

Text content in a multimodal message.

CLASS ImageUrlContent

Image URL content in a multimodal message.

Supports both data URIs (base64-encoded images) and HTTP(S) URLs.

CLASS InputAudioData

Audio data payload for an input_audio content part.

CLASS InputAudioContent

Audio content part in an OpenAI-compatible multimodal message.

Matches the \{"type": "input_audio", "input_audio": \{"data": "...", "format": "wav"\}\} wire format used by the OpenAI Chat Completions API.

CLASS ChatMessage

Chat message with support for text-only or multimodal content.

The content field can be:

  • A string (text-only, backward compatible)
  • None (for messages without content)
  • A list of content objects (multimodal: text, images, audio)

Methods:

FUNC get_text_content

get_text_content(self) -> str

Extract text content from message, handling both string and multimodal formats.

Returns:

  • Concatenated text from all TextContent items, or empty string if no text.
  • Images and audio are ignored (handled separately via extraction utilities).

FUNC get_image_urls

get_image_urls(self) -> list[str]

Extract image URLs from message content.

Returns:

  • List of image URL strings from all ImageUrlContent items.
  • Empty list if content is a string or contains no images.

FUNC get_image_blocks

get_image_blocks(self) -> list[ImageBlock | ImageUrlBlock]

Extract image blocks from message content.

Returns:

  • List of ImageBlock (for base64/data-URI images) or
  • ImageUrlBlock (for http/https URLs) from all ImageUrlContent
  • items. Empty list if content is a string or contains no images.

Raises:

  • ValueError: If an image URL is invalid or cannot be processed.

FUNC get_audio_blocks

get_audio_blocks(self) -> list[AudioBlock]

Extract audio blocks from message content.

Returns:

  • List of AudioBlock instances from all InputAudioContent items.
  • Empty list if content is a string or contains no audio parts.

Raises:

  • ValueError: If an audio data payload is invalid or cannot be processed.