"git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "1681dcae385d1c70f25cdb1151e7cff4342e55ff"
Unverified Commit 39c3c0a7 authored by Zhenwei's avatar Zhenwei Committed by GitHub
Browse files

fix a hidden bug of `GenerationConfig`, now the `generation_config.json` can...


fix a hidden bug of `GenerationConfig`, now the `generation_config.json` can be loaded successfully (#28604)

* fix a hidden bug of GenerationConfig

* keep `sort_keys=True` to maintain visibility

* Update src/transformers/generation/configuration_utils.py
Co-authored-by: default avataramyeroberts <22614925+amyeroberts@users.noreply.github.com>

* Update configuration_utils.py

in case `obj` is a list, check the items in the list

---------
Co-authored-by: default avataramyeroberts <22614925+amyeroberts@users.noreply.github.com>
parent ebc8f47b
......@@ -909,6 +909,16 @@ class GenerationConfig(PushToHubMixin):
for metadata_field in METADATA_FIELDS:
config_dict.pop(metadata_field, None)
def convert_keys_to_string(obj):
if isinstance(obj, dict):
return {str(key): convert_keys_to_string(value) for key, value in obj.items()}
elif isinstance(obj, list):
return [convert_keys_to_string(item) for item in obj]
else:
return obj
config_dict = convert_keys_to_string(config_dict)
return json.dumps(config_dict, indent=2, sort_keys=True) + "\n"
def to_json_file(self, json_file_path: Union[str, os.PathLike], use_diff: bool = True):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment