Skip to content

fix: adaptor proto convert and async usage store load metadata#589

Merged
zijiren233 merged 1 commit into
labring:mainfrom
zijiren233:proto-convert-store
May 24, 2026
Merged

fix: adaptor proto convert and async usage store load metadata#589
zijiren233 merged 1 commit into
labring:mainfrom
zijiren233:proto-convert-store

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 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.Store through AsyncUsageRequest and use the global controller.AdaptorStore in 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.

@zijiren233 zijiren233 merged commit f01389b into labring:main May 24, 2026
16 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