Repository navigation
refactor: update user account identifiers in translations and improve media handling logic - #7930
Merged
Merged
Conversation
… media handling logic
shaohuzhang1
commented
Nov 16, 2026
| self.assertEqual( | ||
| TencentModelProvider.classify_dynamic_model("hunyuan-turbos-vision-video-20250728"), | ||
| ModelTypeConst.TTV, | ||
| ) |
Contributor
Author
There was a problem hiding this comment.
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@classmethodor@staticmethod. If it is an instance method, the tests will fail with a missingselfargument.- Confirm that
ModelTypeConst.IMAGE,ModelTypeConst.ITV, andModelTypeConst.TTVexist and have the intended semantics. In particular, make sureIMAGEmeans “vision/multimodal understanding” here, not “text-to-image generation”; otherwisehunyuan-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 -> ITVexpectation should be confirmed against Tencent’s model documentation. If the classification relies on special substrings such asytorhumanactor, document that rule clearly.
Optimization suggestions
- Use
subTestin 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
visionnorvideo, - false positives such as
televisionorvisionary, - model IDs containing both
visionandvideo.
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.
shaohuzhang1
commented
Nov 16, 2026
|
|
||
| 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-"): |
Contributor
Author
There was a problem hiding this comment.
Here's my review of the diff:
Potential Issues
-
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 asIMAGE. 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.
-
Ordering dependency
yt-videocheck happens beforevision, soyt-video-visionwould go toITV. If such a model can exist, ensure this is intentional and documented.
-
Name collision confusion
- The method is named
classify_dynamic_modelwhile it delegates to the importedclassify_dynamic_model_id. Similar names can cause confusion; consider renaming to something like_classify_tokenhub_modelto signal that this is provider-specific logic.
- The method is named
-
Staticmethod placement
- It's defined between
get_model_info_manageandget_model— fine, but since it's pure (noself), you could also move it near other factory/helper methods for readability.
- It's defined between
-
Case handling
str(model_id).lower()is safe, but ifmodel_idis everNone, you'd get"none"— for consistency withclassify_dynamic_model_id, confirm its expectations so behavior stays aligned.
-
Missing tests
- Add unit tests covering: pure
yt-video-*,*-vision,*-vision-t2v,*-vision-i2v, unknown IDs falling back, and mixed-case inputs.
- Add unit tests covering: pure
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 thanin. - 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
typefield 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.
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.
refactor: update user account identifiers in translations and improve media handling logic