fix: adaptor proto convert and async usage store load metadata#589
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves async-usage billing accuracy and request/response fidelity for multiple video/image adaptors by (1) passing a shared store into async usage fetchers so they can load previously-saved request metadata, and (2) tightening/clarifying resolution handling (including 4K) across validation, usage context, and pricing.
Changes:
- Thread
adaptor.StorethroughAsyncUsageRequestand use the globalcontroller.AdaptorStorein the async-usage poller to enable metadata lookups during async completion. - Expand/standardize resolution support handling: add 4K tier recognition, improve validation errors to include “supported resolutions”, and keep exact
<width>x<height>dimensions for usage/pricing contexts where needed. - Persist and restore request metadata (prompt/resolution/ratio/size/duration) for SiliconFlow, Doubao, and Ali video flows; update adaptors/tests accordingly (including delimiter normalization and provider-field omission in responses).
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| core/task/task.go | Passes controller.AdaptorStore into async usage fetch requests. |
| core/relay/model/video.go | Adds 4K threshold to VideoResolutionFromHeight. |
| core/relay/controller/video.go | Enhances video resolution validation to include supported options and uses fuzzy-match config consistently. |
| core/relay/controller/video_test.go | Updates expected validation messages and adds coverage for advertised 4K size acceptance. |
| core/relay/controller/resolution.go | Centralizes supported-resolution option rendering and improves invalid/unsupported resolution errors (images/videos/Gemini). |
| core/relay/controller/image.go | Improves image resolution validation errors with supported options and passes fuzzy config through. |
| core/relay/controller/image_test.go | Updates image validation error expectations for supported-resolution messaging. |
| core/relay/controller/edits_test.go | Updates edits validation error expectations for supported-resolution messaging. |
| core/relay/adaptor/vertexai/adaptor.go | Provides store to Gemini async-usage helper for metadata reads. |
| core/relay/adaptor/vertexai/adaptor_test.go | Switches async-usage metadata setup to an in-memory store and passes it into requests. |
| core/relay/adaptor/siliconflow/video.go | Saves request metadata to store, restores it on status calls, and emits usage context on submit. |
| core/relay/adaptor/siliconflow/async_usage.go | Loads async usage context (resolution) from stored metadata and merges with request context. |
| core/relay/adaptor/siliconflow/adaptor_test.go | Adds store-aware tests for metadata persistence/restoration and size delimiter normalization. |
| core/relay/adaptor/openai/async_usage.go | Keeps exact <width>x<height> resolution in job pricing/usage context (guards against missing dims). |
| core/relay/adaptor/openai/async_usage_test.go | Updates tests to expect exact dimensions and adds coverage for missing-dimension behavior. |
| core/relay/adaptor/interface.go | Extends AsyncUsageRequest with a Store field. |
| core/relay/adaptor/gemini/video_test.go | Adds content download coverage and moves async-usage metadata setup to an in-memory store. |
| core/relay/adaptor/gemini/image_test.go | Adds dimension→Gemini image-size mapping tests and verifies provider fields are omitted from responses. |
| core/relay/adaptor/gemini/async_usage.go | Reads stored metadata via injected store and improves resolution fallback behavior. |
| core/relay/adaptor/doubao/video.go | Stores/restores request metadata, improves usage context derivation (dims + native tier), and fixes portrait ratio dimension math. |
| core/relay/adaptor/doubao/main_test.go | Updates tests for normalized sizes, response field omission, metadata persistence/restoration, and store-aware async usage. |
| core/relay/adaptor/doubao/image.go | Normalizes request size delimiters and converts provider response into OpenAI-shaped response (omitting provider-only fields). |
| core/relay/adaptor/doubao/async_usage.go | Builds async usage context using stored ratio/resolution where needed and merges with request context. |
| core/relay/adaptor/azure/async_usage.go | Keeps exact <width>x<height> resolution in job pricing (guards against missing dims). |
| core/relay/adaptor/azure/async_usage_test.go | Adjusts test package to access internal helper and adds missing-dimension coverage. |
| core/relay/adaptor/ali/video.go | Stores/restores request metadata, fixes portrait ratio dimension math, and uses stored size to populate width/height fallback. |
| core/relay/adaptor/ali/async_usage.go | Uses stored metadata to derive resolution when upstream ratio is missing; merges with request context. |
| core/relay/adaptor/ali/adaptor_test.go | Updates async usage expectations to exact dimensions and adds store-metadata fallback coverage. |
| core/model/usage_test.go | Strengthens normalization coverage for resolution matching (*, spaces, case). |
| core/controller/relay-controller.go | Exposes AdaptorStore and wires it into request handling. |
💡 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.