|
45 | 45 | "flags": ["--dyn-tool-call-parser"], |
46 | 46 | "type": str, |
47 | 47 | "default": None, |
48 | | - "choices": get_tool_parser_names(), |
49 | 48 | "help": "Tool call parser name for the model.", |
50 | 49 | }, |
51 | 50 | "reasoning-parser": { |
52 | 51 | "flags": ["--dyn-reasoning-parser"], |
53 | 52 | "type": str, |
54 | 53 | "default": None, |
55 | | - "choices": get_reasoning_parser_names(), |
56 | 54 | "help": "Reasoning parser name for the model. If not specified, no reasoning parsing is performed.", |
57 | 55 | }, |
58 | 56 | "custom-jinja-template": { |
@@ -228,30 +226,14 @@ def _set_parser( |
228 | 226 |
|
229 | 227 | Returns: |
230 | 228 | Resolved parser name, preferring Dynamo's value if both set. |
231 | | -
|
232 | | - Raises: |
233 | | - ValueError: If parser name is not valid. |
234 | 229 | """ |
235 | | - # If both are present, give preference to dynamo_str |
236 | 230 | if sglang_str is not None and dynamo_str is not None: |
237 | 231 | logging.warning( |
238 | 232 | f"--dyn-{arg_name} and --{arg_name} are both set. Giving preference to --dyn-{arg_name}" |
239 | 233 | ) |
240 | 234 | return dynamo_str |
241 | | - # If dynamo_str is not set, use try to use sglang_str if it matches with the allowed parsers |
242 | 235 | elif sglang_str is not None: |
243 | 236 | logging.warning(f"--dyn-{arg_name} is not set. Using --{arg_name}.") |
244 | | - if arg_name == "tool-call-parser" and sglang_str not in get_tool_parser_names(): |
245 | | - raise ValueError( |
246 | | - f"--{arg_name} is not a valid tool call parser. Valid parsers are: {get_tool_parser_names()}" |
247 | | - ) |
248 | | - elif ( |
249 | | - arg_name == "reasoning-parser" |
250 | | - and sglang_str not in get_reasoning_parser_names() |
251 | | - ): |
252 | | - raise ValueError( |
253 | | - f"--{arg_name} is not a valid reasoning parser. Valid parsers are: {get_reasoning_parser_names()}" |
254 | | - ) |
255 | 237 | return sglang_str |
256 | 238 | else: |
257 | 239 | return dynamo_str |
@@ -482,6 +464,23 @@ async def parse_args(args: list[str]) -> Config: |
482 | 464 | "reasoning-parser", |
483 | 465 | ) |
484 | 466 |
|
| 467 | + # Validate parser names when using Dynamo's tokenizer (not SGLang's) |
| 468 | + if not parsed_args.use_sglang_tokenizer: |
| 469 | + if tool_call_parser and tool_call_parser not in get_tool_parser_names(): |
| 470 | + logging.error( |
| 471 | + f"Tool call parser '{tool_call_parser}' is not valid when using Dynamo's tokenizer. " |
| 472 | + f"Valid parsers are: {get_tool_parser_names()}. " |
| 473 | + f"Use --use-sglang-tokenizer to delegate tool parsing to SGLang." |
| 474 | + ) |
| 475 | + sys.exit(1) |
| 476 | + if reasoning_parser and reasoning_parser not in get_reasoning_parser_names(): |
| 477 | + logging.error( |
| 478 | + f"Reasoning parser '{reasoning_parser}' is not valid when using Dynamo's tokenizer. " |
| 479 | + f"Valid parsers are: {get_reasoning_parser_names()}. " |
| 480 | + f"Use --use-sglang-tokenizer to delegate reasoning parsing to SGLang." |
| 481 | + ) |
| 482 | + sys.exit(1) |
| 483 | + |
485 | 484 | if parsed_args.custom_jinja_template and parsed_args.use_sglang_tokenizer: |
486 | 485 | logging.error( |
487 | 486 | "Cannot use --custom-jinja-template and --use-sglang-tokenizer together. " |
|
0 commit comments