Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/celeste/modalities/images/providers/byteplus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
ImageParameter.QUALITY: Choice(options=["2K", "3K", "4K"]),
ImageParameter.REFERENCE_IMAGES: ImagesConstraint(max_count=14),
ImageParameter.WATERMARK: Bool(),
ImageParameter.OUTPUT_FORMAT: Choice(options=["png", "jpeg"]),
},
),
Model(
Expand Down Expand Up @@ -173,6 +174,8 @@
ImageParameter.QUALITY: Choice(options=["1K", "1.5K", "2K"]),
ImageParameter.REFERENCE_IMAGES: ImagesConstraint(max_count=10),
ImageParameter.WATERMARK: Bool(),
ImageParameter.OUTPUT_FORMAT: Choice(options=["png", "jpeg"]),
ImageParameter.BACKGROUND: Choice(options=["transparent", "opaque"]),
},
),
Model(
Expand Down Expand Up @@ -217,6 +220,8 @@
ImageParameter.QUALITY: Choice(options=["1K", "1.5K", "2K"]),
ImageParameter.REFERENCE_IMAGES: ImagesConstraint(max_count=10),
ImageParameter.WATERMARK: Bool(),
ImageParameter.OUTPUT_FORMAT: Choice(options=["png", "jpeg"]),
ImageParameter.BACKGROUND: Choice(options=["transparent", "opaque"]),
},
),
]
16 changes: 16 additions & 0 deletions src/celeste/modalities/images/providers/byteplus/parameters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
"""BytePlus parameter mappers for images modality."""

from celeste.parameters import ParameterMapper
from celeste.providers.byteplus.images.parameters import (
BackgroundMapper as _BackgroundMapper,
)
from celeste.providers.byteplus.images.parameters import (
ImageMapper as _ImageMapper,
)
from celeste.providers.byteplus.images.parameters import (
OutputFormatMapper as _OutputFormatMapper,
)
from celeste.providers.byteplus.images.parameters import (
SizeMapper as _SizeMapper,
)
Expand Down Expand Up @@ -33,11 +39,21 @@ class WatermarkMapper(_WatermarkMapper):
name = ImageParameter.WATERMARK


class OutputFormatMapper(_OutputFormatMapper):
name = ImageParameter.OUTPUT_FORMAT


class BackgroundMapper(_BackgroundMapper):
name = ImageParameter.BACKGROUND


BYTEPLUS_PARAMETER_MAPPERS: list[ParameterMapper[ImageContent]] = [
AspectRatioMapper(),
QualityMapper(),
ReferenceImagesMapper(),
WatermarkMapper(),
OutputFormatMapper(),
BackgroundMapper(),
]

__all__ = ["BYTEPLUS_PARAMETER_MAPPERS"]
20 changes: 19 additions & 1 deletion src/celeste/providers/byteplus/images/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,22 @@ class WatermarkMapper(FieldMapper[ImageContent]):
field = "watermark"


__all__ = ["ImageMapper", "SizeMapper", "WatermarkMapper"]
class OutputFormatMapper(FieldMapper[ImageContent]):
"""Map output_format to BytePlus output_format field."""

field = "output_format"


class BackgroundMapper(FieldMapper[ImageContent]):
"""Map background to BytePlus background field."""

field = "background"


__all__ = [
"BackgroundMapper",
"ImageMapper",
"OutputFormatMapper",
"SizeMapper",
"WatermarkMapper",
]
5 changes: 5 additions & 0 deletions tests/unit_tests/test_parameter_wire_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from celeste.modalities.audio.providers.openai import parameters as openai_audio
from celeste.modalities.images.parameters import ImageParameter
from celeste.modalities.images.providers.bfl import parameters as bfl
from celeste.modalities.images.providers.byteplus import parameters as byteplus_images
from celeste.modalities.images.providers.google import parameters as google_images
from celeste.modalities.images.providers.openai import parameters as openai_images
from celeste.modalities.images.providers.topazlabs import parameters as topazlabs
Expand Down Expand Up @@ -50,6 +51,7 @@
IMAGES_VERTEX = google_images.GOOGLE_VERTEX_PARAMETER_MAPPERS
IMAGES_INTERACTIONS = google_images.GOOGLE_INTERACTIONS_PARAMETER_MAPPERS
IMAGES_OPENAI = openai_images.OPENAI_PARAMETER_MAPPERS
IMAGES_BYTEPLUS = byteplus_images.BYTEPLUS_PARAMETER_MAPPERS
AUDIO_GOOGLE = google_audio.GOOGLE_PARAMETER_MAPPERS
AUDIO_GROQ = groq_audio.GROQ_PARAMETER_MAPPERS
AUDIO_OPENAI = openai_audio.OPENAI_PARAMETER_MAPPERS
Expand Down Expand Up @@ -354,6 +356,8 @@ def _at(data: dict[str, Any], path: tuple[str, ...]) -> Any: # noqa: ANN401
("mask",),
{"image_url": "data:image/png;base64,ZnJhbWU="},
),
(IMAGES_BYTEPLUS, IP.OUTPUT_FORMAT, "jpeg", ("output_format",), "jpeg"),
(IMAGES_BYTEPLUS, IP.BACKGROUND, "transparent", ("background",), "transparent"),
(TOPAZ, IP.OUTPUT_WIDTH, 2048, ("output_width",), 2048),
(TOPAZ, IP.OUTPUT_HEIGHT, 1536, ("output_height",), 1536),
(TOPAZ, IP.OUTPUT_FORMAT, "jpeg", ("output_format",), "jpeg"),
Expand Down Expand Up @@ -581,6 +585,7 @@ def test_scalar_parameters_use_provider_wire_shape(
GOOGLE_VERTEX,
IMAGES_VERTEX,
IMAGES_OPENAI,
IMAGES_BYTEPLUS,
AUDIO_GOOGLE,
AUDIO_GROQ,
AUDIO_OPENAI,
Expand Down
Loading