diff --git a/src/agentscope/parsers/parser_base.py b/src/agentscope/parsers/parser_base.py index 8d083bd75..dd56df762 100644 --- a/src/agentscope/parsers/parser_base.py +++ b/src/agentscope/parsers/parser_base.py @@ -158,7 +158,7 @@ def to_metadata( def _filter_content_by_names( self, parsed_response: dict, - keys: Union[str, Sequence[str]], + keys: Union[str, bool, Sequence[str]], allow_missing: bool = False, ) -> Union[str, dict, None]: """Filter the parsed response by keys. If only one key is provided, the @@ -167,7 +167,7 @@ def _filter_content_by_names( their corresponding values. Args: - keys (`Union[str, Sequence[str]]`): + keys (`Union[str, bool, Sequence[str]]`): The key or keys to be filtered. If it's - `False`, `None` will be returned in the `to_content` method - `str`, the corresponding value will be returned diff --git a/tests/parser_test.py b/tests/parser_test.py index 27b8d01fb..0adf3d728 100644 --- a/tests/parser_test.py +++ b/tests/parser_test.py @@ -193,6 +193,7 @@ def test_multitaggedcontentparser(self) -> None: ) def test_DictFilterMixin_default_value(self) -> None: + """Test the default value of the DictFilterMixin class""" mixin = DictFilterMixin( keys_to_memory=True, keys_to_content=True, @@ -204,6 +205,5 @@ def test_DictFilterMixin_default_value(self) -> None: self.assertEqual(mixin.to_metadata(self.gt_dict), None) - if __name__ == "__main__": unittest.main()