Skip to content

[Feature]: support image_embeds in openai api as well #13540

@gyin94

Description

@gyin94

🚀 The feature, motivation and pitch

would it be possible to support image_embeds in openai protocol api as well? And prefix-caching shall be supported via following proposal. thanks.

So users can pass

{
  "type": "image_url",
  "image_url":  {
      "image_url": {"url": f"data:image/embeds;base64,{base64_image}"},
  }
}

use base64 or other more efficient compression method?

import base64
import numpy as np

def encode_base64(arr):
    return base64.b64encode(arr.astype(np.float32).tobytes()).decode('utf-8')

def decode_base64(encoded_str, shape):
    decoded = base64.b64decode(encoded_str)
    return np.frombuffer(decoded, dtype=np.float32).reshape(shape)

cc @youkaichao

Alternatives

No response

Additional context

No response

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions