fix: base64 image need clear image url#590
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves image b64_json responses by ensuring returned image URLs are omitted when base64 content is present, and enhances usage logging by propagating and recording UsageContext (e.g., resolution/quality/tier) for relevant adaptors.
Changes:
- Clear
urlfields in image responses whenresponse_format=b64_jsonand base64 content is successfully produced (OpenAI, SiliconFlow, Ali). - Propagate
UsageContextthrough adaptor results (Ali + SiliconFlow video handlers) and log it inupdateUsageMetrics. - Normalize Gemini image size values to
1K/2K/4Kand update related tests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| core/relay/controller/dohelper.go | Logs UsageContext fields (resolution/native_resolution/quality/service_tier) into request metrics log entries. |
| core/relay/controller/dohelper_test.go | Adds coverage ensuring UsageContext fields are included in logged metrics. |
| core/relay/adaptor/openai/image.go | Clears image url after successful URL→b64_json conversion. |
| core/relay/adaptor/openai/image_test.go | Adds test asserting url is omitted/empty when b64_json is requested and produced. |
| core/relay/adaptor/siliconflow/image.go | Clears image url after successful URL→b64_json conversion for SiliconFlow image responses. |
| core/relay/adaptor/siliconflow/adaptor_test.go | Adds tests for URL clearing in b64_json image responses and verifies video UsageContext propagation. |
| core/relay/adaptor/siliconflow/video.go | Returns UsageContext (resolution) in video status handler results. |
| core/relay/adaptor/ali/image.go | Centralizes URL suppression logic for b64_json responses when base64 content is present. |
| core/relay/adaptor/ali/video.go | Adds UsageContext resolution derivation and improves resolution fallback using stored request metadata when upstream ratio is missing. |
| core/relay/adaptor/ali/adaptor_test.go | Adds tests for URL clearing in b64_json image responses and stored-resolution fallback + UsageContext resolution on video paths. |
| core/relay/adaptor/gemini/image.go | Normalizes Gemini image size outputs to 1K/2K/4K (and adjusts downstream token logic accordingly). |
| core/relay/adaptor/gemini/image_test.go | Updates assertions to match normalized 1K/2K/4K image size outputs. |
| core/relay/adaptor/vertexai/adaptor_test.go | Updates expected Gemini image conversion payload to use 1K imageSize. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.