-
Couldn't load subscription status.
- Fork 485
Replace duplicate logic with normalize_content and normalize_message_to_dict #2152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
... and 40 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
|
||
| def test_normalize_content_with_string(): | ||
| """Test normalize_content with string input.""" | ||
| from autogen.agentchat.utils import normalize_content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you import function in each test? Can we import it on top of the file?
| assert original_str == "Original string" | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove manual-run block from the test file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of pretty same tests for each function. Can we group some of them to parametrized run?
@pytest.mark.parametrize(
("value", "expected"),
(
pytest.param("Hello world", "Hello world", id="regular string")
pytest.param("", "", id="emepty string")
pytest.param(None, "", id="none")
... # etc
)
)
def test_normalize_content(value: Any, expected: str) -> None:
assert normalize_content(value) == expected
Why are these changes needed?
The content normalization pattern is repeated ~15+ times across the codebase. Extract this into a helper function to improve maintainability.
Locations: chat.py:136-138, conversable_agent.py:1082-1087, conversable_agent.py:3984-3987, group_tool_executor.py:208, enforcer.py (multiple), groupchat.py (multiple)
Related issue number
Checks