Skip to content

refactor: update user account identifiers in translations and improve media handling logic - #7930

Merged
wxg0103 merged 1 commit into
v3from
pr@v3@fix_model_and_i18n
Nov 16, 2026
Merged

wxg0103 merged 1 commit into
v3from
pr@v3@fix_model_and_i18n

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

refactor: update user account identifiers in translations and improve media handling logic

self.assertEqual(
TencentModelProvider.classify_dynamic_model("hunyuan-turbos-vision-video-20250728"),
ModelTypeConst.TTV,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The added tests are generally reasonable and do not introduce network calls or obvious runtime/performance concerns. Main points to verify:

Potential issues

  • TencentModelProvider.classify_dynamic_model(...) is called on the class. This only works if the method is a @classmethod or @staticmethod. If it is an instance method, the tests will fail with a missing self argument.
  • Confirm that ModelTypeConst.IMAGE, ModelTypeConst.ITV, and ModelTypeConst.TTV exist and have the intended semantics. In particular, make sure IMAGE means “vision/multimodal understanding” here, not “text-to-image generation”; otherwise hunyuan-t1-vision-* may be classified incorrectly.
  • The tests encode substring-based classification behavior. If the implementation is case-sensitive, uppercase model IDs may fail. Consider normalizing the model ID to lowercase before matching.
  • The hunyuan-turbos-vision-video-* test correctly protects against “vision” overriding “video”, but ensure the implementation explicitly checks video-related patterns before vision-related patterns.
  • The yt-video-humanactor -> ITV expectation should be confirmed against Tencent’s model documentation. If the classification relies on special substrings such as yt or humanactor, document that rule clearly.

Optimization suggestions

  • Use subTest in the loop so a failure clearly identifies which model ID failed:
for model_id in (
    "hy-vision-2.0-instruct",
    "hunyuan-t1-vision-20250916",
    "deepseek/deepseek-v4-flash-vision-exp",
):
    with self.subTest(model_id=model_id):
        self.assertEqual(
            TencentModelProvider.classify_dynamic_model(model_id),
            ModelTypeConst.IMAGE,
        )
  • Add a few edge-case tests:
    • uppercase model IDs,
    • model IDs with neither vision nor video,
    • false positives such as television or visionary,
    • model IDs containing both vision and video.

Minor style note

  • The comments are in Chinese while the surrounding code/tests appear English. This is not a functional issue, but consistency with the repository’s language convention would improve readability.

@wxg0103
wxg0103 merged commit 5514d0e into v3 Nov 16, 2026
3 of 4 checks passed
@wxg0103
wxg0103 deleted the pr@v3@fix_model_and_i18n branch November 16, 2026 05:43

def get_model(self, model_type, model_name, model_credential, **model_kwargs):
# STT 模型:模型名不以 asr- 开头的一律走 Tencent Tokenhub WAND 识别
if model_type == ModelTypeConst.STT.name and not model_name.startswith("asr-"):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's my review of the diff:

Potential Issues

  1. Type inference may be fragile / over-broad

    • if "vision" in model_id: any future model containing "vision" that is not an image-understanding model will be misclassified as IMAGE. String matching on model IDs is brittle; consider a whitelist/prefix map or config-driven mapping instead.
    • The blacklist ("video", "t2v", "i2v") is likely incomplete. Common video conventions like "vid", "i2v", "t2v", "itv", "ti2v", "s2v" (speech-to-video) should be enumerated if you keep this approach.
  2. Ordering dependency

    • yt-video check happens before vision, so yt-video-vision would go to ITV. If such a model can exist, ensure this is intentional and documented.
  3. Name collision confusion

    • The method is named classify_dynamic_model while it delegates to the imported classify_dynamic_model_id. Similar names can cause confusion; consider renaming to something like _classify_tokenhub_model to signal that this is provider-specific logic.
  4. Staticmethod placement

    • It's defined between get_model_info_manage and get_model — fine, but since it's pure (no self), you could also move it near other factory/helper methods for readability.
  5. Case handling

    • str(model_id).lower() is safe, but if model_id is ever None, you'd get "none" — for consistency with classify_dynamic_model_id, confirm its expectations so behavior stays aligned.
  6. Missing tests

    • Add unit tests covering: pure yt-video-*, *-vision, *-vision-t2v, *-vision-i2v, unknown IDs falling back, and mixed-case inputs.

Optimization Suggestions

  • Extract keyword tuples to module-level constants:
    _VIDEO_KEYWORDS = ("video", "t2v", "i2v")
  • Prefer prefix-based matching if the naming is stable (e.g., model_id.startswith("yt-video")) — more explicit and cheaper than in.
  • Consider returning early and logging at debug level when falling back to classify_dynamic_model_id, to help diagnose misclassifications in production.
  • If provider metadata later becomes available (even a type field in /models), prefer that over name heuristics and deprecate this shim.

Style

  • Docstring mixes Chinese comments with English code — acceptable in many codebases, but ensure the project's convention (looks consistent with existing files).
  • No functional defects detected in the shown snippet; the main risk is heuristic misclassification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants