BerriAI / litellm

Python SDK, Proxy Server (LLM Gateway) to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
13.7k stars 1.61k forks source link

[Feature]: Support vision for GPT-4 Turbo #3080

Closed pbarker closed 6 months ago

pbarker commented 6 months ago

The Feature

Vision is now supported for gpt-4 turbo, it appears litellm, at least from the docs, does not yet support this

Motivation, pitch

This is an upgrade to the preview model in a number of areas

Twitter / LinkedIn details

https://www.linkedin.com/in/patrickbarkerco/

ishaan-jaff commented 6 months ago

@pbarker what doc did you look at for this ?

krrishdholakia commented 6 months ago
Screenshot 2024-04-16 at 5 36 54 PM

i see this on the openai docs - https://platform.openai.com/docs/guides/vision

@ishaan-jaff

krrishdholakia commented 6 months ago

Seeing the code now @pbarker, i believe it should work if you just say

import os 
from litellm import completion

os.environ["OPENAI_API_KEY"] = "your-api-key"

# openai call
response = completion(
    model = "gpt-4-turbo", 
    messages=[
        {
            "role": "user",
            "content": [
                            {
                                "type": "text",
                                "text": "What’s in this image?"
                            },
                            {
                                "type": "image_url",
                                "image_url": {
                                "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
                                }
                            }
                        ]
        }
    ],
)
krrishdholakia commented 6 months ago

@pbarker can confirm this works for me

Updated docs with this as well - https://github.com/BerriAI/litellm/commit/96e995f53b1aa992e37f72763f44af605e284c76

Screenshot 2024-04-16 at 5 44 29 PM
pbarker commented 6 months ago

thank you for the speedy fix!