def test_mixed_content_conversion():
    """Test converting a ChatMessage with mixed content blocks to OpenAI format."""
    # Create various blocks
    text_block = TextBlock(text="This is an image:")

    # URL image
    image_url = "https://example.com/image.jpg"
    image_block = ImageBlock(url=image_url)

    # Create message with mixed content
    message = ChatMessage(role=MessageRole.USER, content=[text_block, image_block])

    # Convert to OpenAI format
    openai_message = to_openailike_message_dict(message)

    # Verify correct format for mixed content
    assert openai_message["role"] == "user"
    assert isinstance(openai_message["content"], list)
    assert len(openai_message["content"]) == 2

    text_content = openai_message["content"][0]
    assert text_content["type"] == "text"
    assert text_content["text"] == "This is an image:"

    image_content = openai_message["content"][1]
    assert image_content["type"] == "image_url"
    assert image_content["image_url"]["url"] == image_url
Test converting a ChatMessage with mixed content blocks to OpenAI format.
llama-index-integrations/llms/llama-index-llms-litellm/tests/test_utils.py