Closed
Conversation
Co-authored-by: bchen <bchen@fireworks.ai>
|
Cursor Agent can help with this pull request. Just |
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.
name: Pull Request
about: Propose changes to the codebase
title: "Fix: Improve type safety for reward functions and message content handling"
labels: ''
assignees: ''
Description
This PR addresses several Pyright type errors by improving type safety in reward functions and the
reward_functiondecorator. The primary motivation was to resolve type inconsistencies related to message content and argument types, making the reward functions more robust to different message representations (PydanticMessageobjects or raw dictionaries).Changes include:
reward_functiondecorator ineval_protocol/typed_interface.pyto better handleList[Message]coercion and preserve function signatures, particularly whenUniontypes are involved.messagesandground_truthparameters in affected reward functions to acceptUnion[List[Message], List[Dict[str, Any]]]._to_texthelper function in reward modules to consistently extract string content from various message content types (strorList[ChatCompletionContentPartTextParam]).Messageobjects and dictionary representations.Fixes # (issue)
Implements # (issue)
Type of change
How Has This Been Tested?
The changes were verified by running the project's type checker (
basedpyright) locally.basedpyrightspecifically on theeval_protocol/rewardsdirectory.multiple_choice_math_reward.py,reasoning_steps.py,repetition.py,tag_count.py,typed_interface.py) are resolved or significantly reduced. The four edited reward files are now type-clean, aside from an external optional import warning inrepetition.pyforjieba.Test Configuration:
basedpyrightChecklist:
black .,isort .,flake8 .)Screenshots (if applicable)
Additional context
The optional import warning for
jiebainrepetition.pyremains, as it is an external dependency issue outside the scope of this PR.