refactor: Consolidate model setting checks into a loop

This commit is contained in:
Paul Gauthier (aider) 2025-03-18 12:27:48 -07:00
parent e577bab263
commit 7097e62582

View file

@ -797,25 +797,20 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
# Show warnings about unsupported settings after all model settings are fully resolved # Show warnings about unsupported settings after all model settings are fully resolved
if args.check_model_accepts_settings: if args.check_model_accepts_settings:
warned = False warned = False
if args.reasoning_effort is not None and ( settings_to_check = [
not main_model.accepts_settings or "reasoning_effort" not in main_model.accepts_settings {"arg": args.reasoning_effort, "name": "reasoning_effort"},
): {"arg": args.thinking_tokens, "name": "thinking_tokens"}
warn_setting = "reasoning_effort" ]
io.tool_warning(
f"Warning: The model {main_model.name} may not support the '{warn_setting}'" for setting in settings_to_check:
" setting." if setting["arg"] is not None and (
) not main_model.accepts_settings or setting["name"] not in main_model.accepts_settings
warned = True ):
io.tool_warning(
if args.thinking_tokens is not None and ( f"Warning: The model {main_model.name} may not support the '{setting['name']}'"
not main_model.accepts_settings or "thinking_tokens" not in main_model.accepts_settings " setting."
): )
warn_setting = "thinking_tokens" warned = True
io.tool_warning(
f"Warning: The model {main_model.name} may not support the '{warn_setting}'"
" setting."
)
warned = True
if warned: if warned:
if not io.confirm_ask( if not io.confirm_ask(