Skip to content

Commit 9cb8e8e

Browse files
authored
Remove inaccurate warning message (mlc-ai#1121)
This PR removes an inaccurate warning from mlc-ai#1086, which warns about `model_lib` overriding regardless of whether or not it's actually overridden. With this commit, we only warn if its value is not None.
1 parent 2aa6809 commit 9cb8e8e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

python/mlc_chat/chat_module.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,22 +356,22 @@ def _get_chat_config(config_file_path: str, user_chat_config: Optional[ChatConfi
356356
final_chat_config = None
357357
with open(config_file_path, mode="rt", encoding="utf-8") as f:
358358
json_object = json.load(f)
359-
final_chat_config = ChatConfig._from_json(json_object)
359+
final_chat_config = ChatConfig._from_json(json_object) # pylint: disable=protected-access
360360
if user_chat_config is not None:
361361
# We override using user's chat config
362362
for field in fields(user_chat_config):
363363
field_name = field.name
364-
if field_name == "model_lib":
365-
warn_msg = (
366-
'WARNING: Do not override "model_lib" in ChatConfig. '
367-
"This override will be ignored. "
368-
"Please use ChatModule.model_lib_path to override the full model library path instead."
369-
)
370-
warnings.warn(warn_msg)
371-
continue
372364
field_value = getattr(user_chat_config, field_name)
373365
if field_value is not None:
374-
setattr(final_chat_config, field_name, field_value)
366+
if field_name == "model_lib":
367+
warn_msg = (
368+
'WARNING: Do not override "model_lib" in ChatConfig. '
369+
"This override will be ignored. Please use ChatModule.model_lib_path to "
370+
"override the full model library path instead."
371+
)
372+
warnings.warn(warn_msg)
373+
else:
374+
setattr(final_chat_config, field_name, field_value)
375375
return final_chat_config
376376

377377

0 commit comments

Comments
 (0)