gen_ai_hub.orchestration.models.multimodal_items module

class gen_ai_hub.orchestration.models.multimodal_items.ImageDetailLevel(*values)

Bases: Enum

Controls the resolution and detail level for image analysis.

Attributes:

  • AUTO: The model determines the detail level automatically.

  • LOW: The model uses a low-fidelity, faster version of the image.

  • HIGH: The model uses a high-fidelity version of the image.

AUTO = 'auto'
LOW = 'low'
HIGH = 'high'
class gen_ai_hub.orchestration.models.multimodal_items.TextPart(text: str, type: str = 'text')

Bases: JSONSerializable

Represents a text segment within a multimodal content block.

Args:

  • text: The string content of the text part.

  • type: The type identifier, defaulting to “text”.

text: str
type: str = 'text'
to_dict()

Converts the TextPart instance to a dictionary.

Returns:

A dictionary representation of the TextPart.

Return type:

dict

__init__(text: str, type: str = 'text') None
class gen_ai_hub.orchestration.models.multimodal_items.ImageUrl(url: str, detail: ImageDetailLevel | None = None)

Bases: object

A data structure holding the URL and detail level for an image.

Args:

  • url: The location of the image, as a standard or data URL.

  • detail: The processing detail level for the image.

url: str
detail: ImageDetailLevel | None = None
__init__(url: str, detail: ImageDetailLevel | None = None) None
class gen_ai_hub.orchestration.models.multimodal_items.ImagePart(image_url: ImageUrl, type: str = 'image_url')

Bases: JSONSerializable

Represents an image segment within a multimodal content block.

Args:

  • image_url: An ImageUrl object containing the image’s location and detail level.

  • type: The type identifier, defaulting to “image_url”.

image_url: ImageUrl
type: str = 'image_url'
to_dict()

Converts the ImagePart instance to a dictionary.

Returns:

A dictionary representation of the ImagePart.

Return type:

dict

__init__(image_url: ImageUrl, type: str = 'image_url') None
class gen_ai_hub.orchestration.models.multimodal_items.ImageItem(url: str | None = None, detail: ImageDetailLevel | None = None)

Bases: JSONSerializable

Represents an image for use in multimodal messages.

Examples:

Using a standard URL img1 = ImageItem(url=”https://example.com/image.png”, detail=ImageDetailLevel.HIGH)

Using a data URL img2 = ImageItem(url=”data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA…”)

__init__(url: str | None = None, detail: ImageDetailLevel | None = None)

Initializes an ImageItem instance.

Parameters:
static from_file(file_path: str, mime_type: str | None = None, detail: ImageDetailLevel | None = None) ImageItem

Creates an ImageItem from a local image file.

Parameters:
  • file_path (str) – Path to the image file.

  • mime_type (Optional[str], optional) – Explicit MIME type (e.g., ‘image/png’). If not provided, the MIME type will be guessed from the file extension.

  • detail (Optional[ImageDetailLevel], optional) – The image detail level for model processing.

Raises:
  • ValueError – If the MIME type cannot be determined and is not provided.

  • FileNotFoundError – If the file does not exist.

Returns:

An ImageItem instance with the image data as a data URL.

Return type:

ImageItem

to_dict() Dict[str, Any]

Converts the ImageItem instance to a dictionary representation.

Returns:

A dictionary representation of the ImageItem.

Return type:

Dict[str, Any]