def generate_bedrock_multi_modal_message(
    prompt: str,
    image_documents: Optional[Sequence[ImageDocument]] = None,
) -> Dict[str, Any]:
    """Generate message for Bedrock multi-modal API."""
    if image_documents is None:
        return {"role": "user", "content": [{"type": "text", "text": prompt}]}

    message_content = []
    # Add text content first
    message_content.append({"type": "text", "text": prompt})

    # Add image content
    for image_document in image_documents:
        image_content = {}
        if image_document.image_path:
            base64_image = encode_image(image_document.image_path)
            image_content = {
                "type": "image",
                "source": {
                    "type": "base64",
                    "media_type": "image/jpeg",  # Default to JPEG
                    "data": base64_image,
                },
            }
        elif "file_path" in image_document.metadata:
            base64_image = encode_image(image_document.metadata["file_path"])
            image_content = {
                "type": "image",
                "source": {
                    "type": "base64",
                    "media_type": "image/jpeg",  # Default to JPEG
                    "data": base64_image,
                },
            }
        elif image_document.image:
            image_content = {
                "type": "image",
                "source": {
                    "type": "base64",
                    "media_type": "image/jpeg",  # Default to JPEG
                    "data": image_document.image,
                },
            }

        if image_content:
            message_content.append(image_content)

    return {"role": "user", "content": message_content}
Generate message for Bedrock multi-modal API.
llama-index-integrations/multi_modal_llms/llama-index-multi-modal-llms-bedrock/llama_index/multi_modal_llms/bedrock/utils.py