You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A single image passed as a bare string/bytes is iterated character-by-character #734
chat/generate accept images as a sequence, but a bare str or bytes is itself a Sequence, so _copy_images iterates it element-wise and wraps each character/byte in its own Image:
client.chat(model='m', messages=[{'role': 'user', 'content': 'hi', 'images': 'aW1hZ2U='}])
# 6 "images" ('a', 'W', '1', ...) -> PydanticSerializationError:# ValueError: Invalid image data, expected base64 string or path to image fileclient.generate(model='m', prompt='hi', images='/tmp/photo.png')
# '/tmp/photo.png' becomes 14 one-character image values, starting with '/'# (which happens to exist as a directory -> IsADirectoryError)
Expected behavior
A single image value (str, bytes, path-like, or Image) is treated as one image, producing images: [<value>] in the request — matching what callers intend and what the API expects.
I'd like to take this. Plan: treat a bare str, bytes, or Image passed as images as a single image in _copy_images (and message image fields), instead of iterating characters or bytes. I'll add unit tests. A PR will follow shortly.
Activity
ZYZ666-RGB commentedon Nov 25, 2026
I'd like to take this. Plan: treat a bare
str,bytes, orImagepassed asimagesas a single image in_copy_images(and message image fields), instead of iterating characters or bytes. I'll add unit tests. A PR will follow shortly.