github BerriAI/litellm v1.28.2

latest releases: v1.46.8, v1.46.7, v1.46.6...
6 months ago

What's Changed

Feature - Pass Base64 encoded images to vertex_ai/gemini-pro-vision

Docs: https://docs.litellm.ai/docs/providers/vertex#gemini-pro-vision

import litellm

def encode_image(image_path):
    import base64

    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")

image_path = "cached_logo.jpg"
# Getting the base64 string
base64_image = encode_image(image_path)
response = litellm.completion(
    model="vertex_ai/gemini-pro-vision",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Whats in this image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "data:image/jpeg;base64," + base64_image
                    },
                },
            ],
        }
    ],
)
print(response)

New Contributors

Full Changelog: v1.28.1...v1.28.2

Don't miss a new litellm release

NewReleases is sending notifications on new releases.