gen_ai_hub.orchestration_v2.models.multimodal_items module¶
Models for representing multimodal content parts, including text and images.
- class gen_ai_hub.orchestration_v2.models.multimodal_items.ImageDetailLevel(*values)¶
Bases:
EnumControls the resolution and detail level for image analysis.
- 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_v2.models.multimodal_items.TextPart(*, text: str, type: Literal['text'] = 'text')¶
Bases:
ABCBaseModelRepresents a text segment within a multimodal content block.
- Parameters:
text – The string content of the text part.
type – The type identifier, defaulting to “text”.
- text: str¶
- type_: Literal['text']¶
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.multimodal_items.ImageUrl(*, url: str, detail: ImageDetailLevel | None = None)¶
Bases:
ABCBaseModelA data structure holding the URL and detail level for an image.
- Parameters:
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¶
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.multimodal_items.ImagePart(*, image_url: ImageUrl, type: Literal['image_url'] = 'image_url')¶
Bases:
ABCBaseModelRepresents an image segment within a multimodal content block.
- Parameters:
image_url – An ImageUrl object containing the image’s location and detail level.
type – The type identifier, defaulting to “image_url”.
- type_: Literal['image_url']¶
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.multimodal_items.ImageItem(*, url: str | None = None, detail: ImageDetailLevel | None = None)¶
Bases:
ABCBaseModelRepresents an image for use in multimodal messages.
- Parameters:
url –
The image location, specified as either a standard URL or a data URL. - Standard URL example: ‘https://example.com/image.png’
Data URL example: ‘data:image/png;base64,…’
detail – The image detail level for model processing.
Example
# 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…”)
- url: str | None¶
- detail: ImageDetailLevel | None¶
- static from_file(file_path: str, mime_type: str | None = None, detail: ImageDetailLevel | None = None) ImageItem¶
Create 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.
- Returns:
An ImageItem instance with the image data as a data URL.
- Return type:
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool = True, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False) dict[str, Any]¶
Dumps the model to a dictionary with default settings.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].