feat: BaseTextQuality根据score来判断#379
Merged
shijinpjlab merged 1 commit intoMigoXLab:devfrom Apr 1, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the text quality evaluation logic in base_text_quality.py to determine status and labels based on a numerical score of 1 rather than a type string. The review feedback suggests refactoring the repeated score comparison into a boolean variable to improve readability and restoring explanatory comments for the counter-intuitive status field logic.
Comment on lines
50
to
+54
| result = EvalDetail( | ||
| metric=cls.__name__, | ||
| status=not is_good, # True if Bad (issues found), False if Good | ||
| status=False if response_model.score == 1 else True, | ||
| score=response_model.score, | ||
| label=["QUALITY_GOOD"] if is_good else [f"{response_model.type}.{response_model.name}"], | ||
| label=["QUALITY_GOOD"] if response_model.score == 1 else [f"{response_model.type}.{response_model.name}"], |
Contributor
There was a problem hiding this comment.
条件 response_model.score == 1 在此处被重复使用了两次。建议将其提取为一个布尔变量(如 is_good),这样可以提高代码的可读性并遵循 DRY(Don't Repeat Yourself)原则。此外,建议保留关于 status 字段含义的注释,因为 status=False 表示“良好”这种逻辑比较反直觉,注释有助于后续维护。这符合 PEP 8 关于代码清晰度的建议。
Suggested change
| result = EvalDetail( | |
| metric=cls.__name__, | |
| status=not is_good, # True if Bad (issues found), False if Good | |
| status=False if response_model.score == 1 else True, | |
| score=response_model.score, | |
| label=["QUALITY_GOOD"] if is_good else [f"{response_model.type}.{response_model.name}"], | |
| label=["QUALITY_GOOD"] if response_model.score == 1 else [f"{response_model.type}.{response_model.name}"], | |
| is_good = response_model.score == 1 | |
| result = EvalDetail( | |
| metric=cls.__name__, | |
| status=not is_good, # False 表示质量良好,True 表示存在问题 | |
| score=response_model.score, | |
| label=["QUALITY_GOOD"] if is_good else [f"{response_model.type}.{response_model.name}"], |
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.