def _llama_to_azure_content_blocks(
        self, chat_messages: List[ChatMessage]
    ) -> list[MessageInputContentBlock]:
        """
        Internal: Convert a list of LlamaIndex ChatMessage to a list of Azure MessageInputContentBlock.
        Supports text and image blocks. Extend as needed for audio/document.
        """
        from azure.ai.agents.models import (
            MessageInputTextBlock,
            MessageInputImageFileBlock,
            MessageInputImageUrlBlock,
            MessageImageFileParam,
            MessageImageUrlParam,
        )

        azure_blocks: list[MessageInputContentBlock] = []
        for msg in chat_messages:
            for block in getattr(msg, "blocks", []):
                if isinstance(block, TextBlock):
                    azure_blocks.append(MessageInputTextBlock(text=block.text))
                elif isinstance(block, ImageBlock):
                    if block.path or block.image:
                        file_id = str(block.path) if block.path else None
                        if file_id:
                            azure_blocks.append(
                                MessageInputImageFileBlock(
                                    image_file=MessageImageFileParam(
                                        file_id=file_id, detail=block.detail
                                    )
                                )
                            )
                    elif block.url:
                        azure_blocks.append(
                            MessageInputImageUrlBlock(
                                image_url=MessageImageUrlParam(
                                    url=str(block.url), detail=block.detail
                                )
                            )
                        )
                else:
                    raise ValueError(f"Unsupported block type: {type(block)}")

        return azure_blocks

        Internal: Convert a list of LlamaIndex ChatMessage to a list of Azure MessageInputContentBlock.
        Supports text and image blocks. Extend as needed for audio/document.
        
llama-index-integrations/agent/llama-index-agent-azure/llama_index/agent/azure_foundry_agent/base.py