Skip to content

Support per-image aspect ratios in generate_images#563

Open
abi wants to merge 1 commit intomainfrom
abi/image-aspect-ratios
Open

Support per-image aspect ratios in generate_images#563
abi wants to merge 1 commit intomainfrom
abi/image-aspect-ratios

Conversation

@abi
Copy link
Owner

@abi abi commented Feb 26, 2026

This updates generate_images to use prompt objects with optional per-image aspect_ratio and removes batch-level aspect ratio handling. It adds shared aspect-ratio constants and validation, and threads aspect ratio through Flux generation while allowing providers like DALL-E to ignore it. It also updates the system prompt guidance and Agent Activity UI to surface aspect ratios in a muted way per image. Tests were expanded to cover schema compatibility (including OpenAI strict tool schema), per-image batching, and validation behavior.

@abi
Copy link
Owner Author

abi commented Feb 26, 2026

  • Tough one.
  • Do we want the additional complexity of aspect ratio?
  • NYTImes is much better. OpenAI is better too.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c86d59542c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +243 to +244
raw_aspect_ratio = item.get("aspect_ratio", DEFAULT_ASPECT_RATIO)
if not is_supported_aspect_ratio(raw_aspect_ratio):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat null aspect_ratio as default in generate_images

The OpenAI strict tool schema now permits aspect_ratio: null for prompt items (see _make_responses_schema_strict, which marks properties nullable and appends null to enums), but this validator rejects that payload: item.get("aspect_ratio", DEFAULT_ASPECT_RATIO) returns None when the key is present with null, then is_supported_aspect_ratio(None) fails and the tool errors. That makes schema-valid strict tool calls fail at runtime instead of falling back to the default aspect ratio.

Useful? React with 👍 / 👎.

)

grouped_items = list(grouped_requests.items())
grouped_results = await asyncio.gather(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep Replicate batching global across aspect-ratio groups

Launching one process_tasks call per aspect-ratio group via asyncio.gather removes the previous global concurrency cap for Flux requests: each group enforces REPLICATE_BATCH_SIZE independently, so mixed-ratio requests can now issue groups × REPLICATE_BATCH_SIZE concurrent Replicate calls. This increases burst load and can trigger rate-limit or stability issues for prompts that span multiple aspect ratios.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant