-
Notifications
You must be signed in to change notification settings - Fork 20
Closed
Description
Summary
Multiple provider clients manually call base64.b64decode() before passing data to ImageArtifact(data=...) or VideoArtifact(data=...). The Artifact base class already has a @field_validator("data", mode="before") that automatically decodes base64 strings to bytes. We should pass the base64 string directly and let the validator handle it.
Already fixed in #135 (Vertex PR) for Google providers:
modalities/images/providers/google/gemini.pymodalities/images/providers/google/imagen.pymodalities/videos/providers/google/client.py
Remaining instances
modalities/images/providers/openai/client.py(lines 64, 146)modalities/images/providers/xai/client.py(line 87)modalities/images/providers/ollama/client.py(lines 56, 118)modalities/images/providers/byteplus/client.py(lines 83, 165)modalities/videos/providers/openai/client.py(line 58)modalities/audio/providers/google/client.py(line 65)
Pattern
Replace:
image_bytes = base64.b64decode(base64_data)
artifacts.append(ImageArtifact(data=image_bytes, ...))With:
artifacts.append(ImageArtifact(data=base64_data, ...))Remove unused import base64 where applicable.
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels