[Bugfix] Fix --config arg expansion called from api_server.py (#23944)

Signed-off-by: Jean-Francois Dube <dubejf+gh@gmail.com>
Co-authored-by: Jean-Francois Dube <dubejf+gh@gmail.com>
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
dubejf
2025-08-29 21:36:39 -07:00
committed by GitHub
co-authored by Jean-Francois Dube Cyrus Leung
parent d660c98c1b
commit 5b31cb1781
2 changed files with 27 additions and 2 deletions
+5 -2
View File
@@ -1976,13 +1976,16 @@ class FlexibleArgumentParser(ArgumentParser):
config_args = self.load_config_file(file_path)
# 0th index is for {serve,chat,complete}
# 0th index might be the sub command {serve,chat,complete,...}
# optionally followed by model_tag (only for serve)
# followed by config args
# followed by rest of cli args.
# maintaining this order will enforce the precedence
# of cli > config > defaults
if args[0] == "serve":
if args[0].startswith('-'):
# No sub command (e.g., api_server entry point)
args = config_args + args[0:index] + args[index + 2:]
elif args[0] == "serve":
model_in_cli = len(args) > 1 and not args[1].startswith('-')
model_in_config = any(arg == '--model' for arg in config_args)