Repository navigation
feat(byteplus): map output_format and background on Seedream images - #590
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BytePlus image models warn about
output_formatandbackground(UnsupportedParameterWarning) and drop them. Celeste has the unifiedImageParameter.OUTPUT_FORMATandImageParameter.BACKGROUND, and OpenAI maps both, but BytePlus has no mapper for either. #520 left this as follow-up work ("That needs a BytePlusOutputFormatMapper").The ModelArk Image generation API documents both request fields:
output_format: "string Default jpeg | Image format". "Specifies the file format of the generated image. Valid values: png, jpeg". Supported models: "Seedream 5.0 pro, Seedream 5.0 flash, Seedream 5.0 lite".background: "string Default opaque | Image alpha channel". "Controls whether to generate an image with an alpha channel. Valid values: transparent [...] opaque". Supported models: "Seedream 5.0 pro, Seedream 5.0 flash". Transparent mode "is supported only for image-to-image generation with exactly one input image that has an alpha channel", and "If output_format is set to jpeg, the request returns an error."Fix:
src/celeste/providers/byteplus/images/parameters.py: wireOutputFormatMapper(output_format) andBackgroundMapper(background).src/celeste/modalities/images/providers/byteplus/parameters.py: the two mappers are bound toImageParameter.OUTPUT_FORMAT/ImageParameter.BACKGROUNDand added toBYTEPLUS_PARAMETER_MAPPERS.src/celeste/modalities/images/providers/byteplus/models.py, with literals verbatim from the reference:OUTPUT_FORMAT: Choice(["png", "jpeg"])onseedream-5-0-260128(lite),dola-seedream-5-0-pro-260628anddola-seedream-5-0-flash-260915;BACKGROUND: Choice(["transparent", "opaque"])on pro and flash.output_format(fix(byteplus): label image outputs with their declared format instead of PNG #520).tests/unit_tests/test_parameter_wire_contracts.py:output_formatandbackgroundrows for the BytePlus images list, which also joins the none-omits list.CHANGELOG.md: one Features line under[Unreleased].Validation:
make cipasses (766 tests).dola-seedream-5-0-flash-260915withoutput_format="jpeg", background="transparent":origin/main: neither field is sent, and twoUnsupportedParameterWarnings are raised;output_format: "jpeg"andbackground: "transparent"are sent, with no warnings.artifact.mime_typegenerate(output_format="jpeg", quality="1K")image/jpegff d8 ff e0(JPEG), 1248×832, 182,610 Bedit(image=<512×512 RGBA PNG, red disc on transparent>, background="transparent", quality="1K")image/pngrgba(IHDR color type 6). Alpha: 89.7% of pixels below 32 (background), 9.8% at 224 or above (the blue star)generate(output_format="png", quality="2K")Nonergb24(BytePlus defaults to jpeg, so the field was applied)output_formatbut does not declare it in the response. The reference listsdata.output_formatonly for 5.0 pro and flash, so lite output stays unlabeled. This is the same as fix(byteplus): label image outputs with their declared format instead of PNG #520: an undeclared format staysNone, as for OpenAI, BFL and Topaz Labs. Streaming events document nooutput_formateither.