-
Notifications
You must be signed in to change notification settings - Fork 28
fix: pass quality parameter to openai-image provider #54
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -61,6 +61,13 @@ func (p *OpenAIImageProvider) ValidateParams(params map[string]interface{}) erro | |||||||||||||||||||||||||
| return fmt.Errorf("size 仅支持 auto、1024x1024、1024x1536、1536x1024") | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| quality, _ := params["quality"].(string) | ||||||||||||||||||||||||||
| switch strings.TrimSpace(strings.ToLower(quality)) { | ||||||||||||||||||||||||||
| case "", "auto", "low", "medium", "high": | ||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||
| return fmt.Errorf("quality 仅支持 auto、low、medium、high") | ||||||||||||||||||||||||||
|
Comment on lines
+64
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Do not accept Severity Level: Minor Why it matters? 🤔The final file state explicitly accepts and validates Fix in Cursor | Fix in VSCode Claude (Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** backend/internal/provider/openai_image.go
**Line:** 64:68
**Comment:**
*Custom Rule: Do not accept `quality` as a valid input for `openai-image`; treat it as unsupported for this provider (or explicitly reject when provided) to align with the project rule that gpt-image-2 does not support quality settings.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix |
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议在
Suggested change
References
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -140,6 +147,9 @@ func (p *OpenAIImageProvider) buildImagesGenerationRequestBody(modelID string, p | |||||||||||||||||||||||||
| if size, _ := params["size"].(string); strings.TrimSpace(size) != "" { | ||||||||||||||||||||||||||
| body.Size = strings.TrimSpace(strings.ToLower(size)) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if quality, _ := params["quality"].(string); strings.TrimSpace(quality) != "" { | ||||||||||||||||||||||||||
| body.Quality = strings.TrimSpace(strings.ToLower(quality)) | ||||||||||||||||||||||||||
|
Comment on lines
+150
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Stop mapping Severity Level: Minor Why it matters? 🤔The code serializes Fix in Cursor | Fix in VSCode Claude (Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** backend/internal/provider/openai_image.go
**Line:** 150:151
**Comment:**
*Custom Rule: Stop mapping `quality` into the OpenAI Images request payload for `openai-image`, so requests do not include unsupported endpoint parameters.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix |
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+150
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 此处对
Suggested change
References
|
||||||||||||||||||||||||||
| if count, ok := toInt(params["count"]); ok && count >= 1 && count <= 10 { | ||||||||||||||||||||||||||
| body.N = count | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
Suggestion: The new quality validation silently accepts non-string values because
params["quality"].(string)ignores failed type assertions and falls back to"", which passes the whitelist. This means inputs like numbers/objects bypass validation and are then dropped from the request body, causing incorrect behavior instead of a clear 400 error. Validate the type explicitly when the key is present, and return an error ifqualityis not a string. [type error]Severity Level: Major⚠️
Steps of Reproduction ✅
Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖