-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ollama.py for image handling #2888
Update ollama.py for image handling #2888
Conversation
Some clients (eg librechat) send images in datauri format, not plain base64. Strip off the prerix when passing images to ollama.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
ollama wants plain base64 jpeg images, and some clients send dataURI and/or webp. Remove prefixes and convert all non-jpeg images to jpeg.
Hi Jakob,
base64 encoded data shouldn't contain commas, it's restricted to the
character set [A-Za-z0-9/+=]: https://en.wikipedia.org/wiki/Base64
…On Thu, 11 Apr 2024 at 05:10, Jakob ***@***.***> wrote:
I think this implementation is flawed since you're doing image.split(",")
for the comma you're expecting at the beginning, but the base64 encoded
data itself can also contain commas.
—
Reply to this email directly, view it on GitHub
<#2888 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADSBEJVKJCF77L263ZUULTTY4X5LTAVCNFSM6AAAAABF3HOAX6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBYHA2TKNBRGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yeah realized that afterwards and deleted my comment :) sorry about that. I was confusing "," with "/" |
@rick-github thanks for this - can you add a test with a mock call for this to place to add test - Example of a mock call - litellm/litellm/tests/test_completion.py Line 1314 in b29994a
|
Done. |
Thanks @rick-github just share a screenshot of it passing testing for your test + tests in Thank you again for your awesome work here |
LGTM! |
ollama wants plain base64 jpeg/png images, and some clients send dataURI and/or webp. Remove prefixes and convert all non-jpeg/png images to jpeg.
Fixes #1427, #2661