fix: allowed_resolutions and fuzzy match allowed_resolutions#587
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR unifies image/video resolution restrictions into a single allowed_resolutions field and introduces fuzzy matching between common equivalent resolution formats (e.g., 1280x720 ↔ 720p, 1024x1024 ↔ 1k). It also surfaces request billing context (resolution/quality/service tier) in the web log table and aligns Gemini native video error wrapping with Gemini-style error responses.
Changes:
- Replace
image_resolutions/video_resolutionsconfig keys with a unifiedallowed_resolutionsmodel field across web + core, with fuzzy alias matching and opt-out (disable_resolution_fuzzy_match). - Add strict request-format validation for OpenAI video/image size fields and Gemini native video
resolution. - Add
usage_contextdisplay in the web log table and add/adjust translations.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/validation/model.ts | Updates model create validation to accept allowed_resolutions; removes old resolution config keys. |
| web/src/types/model.ts | Updates model types to include allowed_resolutions; removes old image_resolutions/video_resolutions fields. |
| web/src/types/log.ts | Adds LogUsageContext type and usage_context field on log records. |
| web/src/feature/model/components/ModelForm.tsx | Updates model form UI to edit allowed_resolutions and removes old image/video resolution inputs. |
| web/src/feature/log/components/LogTable.tsx | Adds a “Billing Conditions” column rendering usage_context fields. |
| web/public/locales/zh/translation.json | Adds new i18n keys for allowed resolutions + billing context; removes old resolution keys. |
| web/public/locales/en/translation.json | Adds new i18n keys for allowed resolutions + billing context; removes old resolution keys. |
| core/relay/model/gemini.go | Adds Gemini error wrapper helpers (WrapperGeminiError*). |
| core/relay/model/errors.go | Routes Gemini video modes to Gemini-style errors; keeps OpenAI video errors for OpenAI video modes. |
| core/relay/model/errors_test.go | Adds regression tests for wrapper error selection between Gemini/OpenAI video modes. |
| core/relay/controller/video.go | Adds request-format validation and switches resolution restriction checks to AllowedResolutions with fuzzy alias matching. |
| core/relay/controller/video_test.go | Updates/extends video controller tests for new validation + fuzzy resolution behavior. |
| core/relay/controller/resolution.go | Introduces shared normalization + fuzzy alias matching helpers for resolution checks. |
| core/relay/controller/image.go | Switches image resolution restriction checks to AllowedResolutions + shared helpers; adds strict size format validation. |
| core/relay/controller/image_test.go | Updates/extends image controller tests for strict format + fuzzy matching behavior. |
| core/relay/controller/edits_test.go | Updates edits request tests to use AllowedResolutions and adds invalid-format coverage. |
| core/relay/adaptor/gemini/video.go | Wraps Gemini native video internal errors using Gemini-style errors. |
| core/relay/adaptor/doubao/constants_test.go | Updates test payloads to use OpenAI-style dimension sizes. |
| core/model/modelconfig.go | Adds persisted AllowedResolutions field to ModelConfig. |
| core/model/configkey.go | Removes old config keys/options related to image/video resolutions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| supportedExact := normalizeSupportedResolutionValues(supported) | ||
| if len(supportedExact) == 0 || slices.Contains(supportedExact, resolution) { |
Comment on lines
+193
to
+210
| const context = row.original.usage_context | ||
| const items = [ | ||
| context?.resolution && `${t('log.resolution')}: ${context.resolution}`, | ||
| context?.quality && `${t('log.quality')}: ${context.quality}`, | ||
| context?.service_tier && `${t('log.serviceTier')}: ${context.service_tier}`, | ||
| ].filter(Boolean) | ||
|
|
||
| if (items.length === 0) { | ||
| return <div className="text-sm text-muted-foreground">-</div> | ||
| } | ||
|
|
||
| return ( | ||
| <div className="flex flex-wrap gap-1"> | ||
| {items.map((item) => ( | ||
| <Badge key={item} variant="outline" className="text-xs font-normal"> | ||
| {item} | ||
| </Badge> | ||
| ))} |
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.
No description provided.