-
Notifications
You must be signed in to change notification settings - Fork 663
feat: add OpenAI image generation settings #1591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # OpenAI Image Generation Settings Plan | ||
|
|
||
| ## Architecture | ||
|
|
||
| - Keep the shared `ImageGenerationOptions` type and contracts. | ||
| - Rename gpt-image-2-specific helpers, constants, validators, and UI component names to OpenAI image generation settings names. | ||
| - Store session image settings as JSON in `deepchat_sessions`; keep the existing v27 migration. | ||
| - Keep model-level settings in the existing model config JSON store. | ||
|
|
||
| ## Data Flow | ||
|
|
||
| - Settings dialog writes model-level `imageGeneration` when `supportsOpenAIImageGenerationSettings(...)` is true. | ||
| - Chat status bar writes session-level `imageGeneration` under the same capability check. | ||
| - Agent runtime merges effective session settings into `ModelConfig`. | ||
| - AI SDK runtime passes `size` at the `generateImage()` top level and OpenAI provider options through `providerOptions`. | ||
|
|
||
| ## Compatibility | ||
|
|
||
| - Existing sessions without image settings behave exactly as before. | ||
| - Empty or invalid stored image settings are treated as unset. | ||
| - Existing chat-model settings remain unchanged for models outside the OpenAI image settings capability. | ||
| - The `deepchat_sessions` migration stays at version 27 because the global schema version is already 26. | ||
|
|
||
| ## Tests | ||
|
|
||
| - Runtime tests use `gpt-image-2` for empty options and option forwarding. | ||
| - Contract and SQLite tests verify config round trips. | ||
| - Renderer component tests use `gpt-image-2` as the positive image settings fixture and existing chat model ids as generic fallbacks. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # OpenAI Image Generation Settings Spec | ||
|
|
||
| ## User Story | ||
|
|
||
| Users who select an OpenAI or OpenAI-compatible image generation model can configure image generation parameters without seeing chat-only settings that do not affect image generation. | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| - OpenAI image-generation routes, image endpoints, imageGeneration model types, and the current `gpt-image-2` fallback use the image-specific settings UI. | ||
| - Default UI choices do not persist or send image generation parameters. | ||
| - Model-level image settings define defaults for new sessions. | ||
| - Session-level image settings can override model-level settings. | ||
| - Runtime forwards only valid OpenAI image options to AI SDK image generation. | ||
| - Invalid custom sizes cannot be saved from the UI. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - Do not add support for `n`, `partial_images`, streaming partial images, `input_fidelity`, `style`, or `user`. | ||
| - Do not add transparent background support. | ||
| - Do not test future or unconfirmed model ids. | ||
|
|
||
| ## Constraints | ||
|
|
||
| - Public config fields remain under `imageGeneration`. | ||
| - Unset options must remain `undefined` so OpenAI defaults apply. | ||
| - Supported stored fields are `size`, `quality`, `outputFormat`, `outputCompression`, `background`, and `moderation`. | ||
| - Custom sizes must use `{width}x{height}`, both dimensions must be multiples of 16, each side must be at most 3840, aspect ratio must be at most 3:1, and total pixels must be between 655360 and 8294400. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # OpenAI Image Generation Settings Tasks | ||
|
|
||
| - [x] Define SDD artifacts. | ||
| - [x] Add shared image option types, validation, and contracts. | ||
| - [x] Persist session image settings. | ||
| - [x] Forward image settings in AI SDK runtime. | ||
| - [x] Add image-generation-specific settings UI. | ||
| - [x] Generalize naming from gpt-image-2 to OpenAI image generation settings. | ||
| - [x] Keep tests focused on `gpt-image-2` and existing non-image models. | ||
| - [x] Run format, i18n, lint, typecheck, and focused tests. |
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imageGenerationpersistence is write-only right now.Line 3037 through Line 3039 writes the field, but the session load mapper (
mapPersistedGenerationPatch) does not restore persisted image options. Session overrides can be lost after process restart.Suggested fix (read-path symmetry)
type PersistedSessionGenerationRow = { provider_id: string model_id: string permission_mode: PermissionMode system_prompt: string | null temperature: number | null context_length: number | null max_tokens: number | null timeout_ms: number | null thinking_budget: number | null reasoning_effort: SessionGenerationSettings['reasoningEffort'] | null reasoning_visibility: SessionGenerationSettings['reasoningVisibility'] | null verbosity: SessionGenerationSettings['verbosity'] | null force_interleaved_thinking_compat: number | null + image_generation_options_json: string | null } // inside mapPersistedGenerationPatch(...) if (typeof sessionRow.force_interleaved_thinking_compat === 'number') { patch.forceInterleavedThinkingCompat = sessionRow.force_interleaved_thinking_compat === 1 } +if (typeof sessionRow.image_generation_options_json === 'string') { + try { + const parsed = JSON.parse(sessionRow.image_generation_options_json) as unknown + const imageGeneration = normalizeImageGenerationOptions(parsed) + if (imageGeneration) { + patch.imageGeneration = imageGeneration + } + } catch { + // ignore invalid persisted payload + } +}🤖 Prompt for AI Agents