Skip to content

fix: allowed_resolutions and fuzzy match allowed_resolutions#587

Merged
zijiren233 merged 5 commits into
labring:mainfrom
zijiren233:allowed-match
May 24, 2026
Merged

fix: allowed_resolutions and fuzzy match allowed_resolutions#587
zijiren233 merged 5 commits into
labring:mainfrom
zijiren233:allowed-match

Conversation

@zijiren233
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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., 1280x720720p, 1024x10241k). 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_resolutions config keys with a unified allowed_resolutions model 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_context display 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.

Comment thread core/relay/controller/resolution.go Outdated
}

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>
))}
@zijiren233 zijiren233 merged commit 9ba9640 into labring:main May 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants