|
13 | 13 |
|
14 | 14 | logger = init_logger(__name__) |
15 | 15 |
|
| 16 | +VLLM_SERVE_PARSER_EPILOG = ( |
| 17 | + "Tip: Use `vllm serve --help=<keyword>` to explore arguments from help.\n" |
| 18 | + " - To view a argument group: --help=ModelConfig\n" |
| 19 | + " - To view a single argument: --help=max-num-seqs\n" |
| 20 | + " - To search by keyword: --help=max\n" |
| 21 | + " - To list all groups: --help=listgroup") |
| 22 | + |
16 | 23 |
|
17 | 24 | async def listen_for_disconnect(request: Request) -> None: |
18 | 25 | """Returns if a disconnect message is received""" |
@@ -158,3 +165,55 @@ def _validate_truncation_size( |
158 | 165 | tokenization_kwargs["max_length"] = truncate_prompt_tokens |
159 | 166 |
|
160 | 167 | return truncate_prompt_tokens |
| 168 | + |
| 169 | + |
| 170 | +def show_filtered_argument_or_group_from_help(parser): |
| 171 | + import sys |
| 172 | + for arg in sys.argv: |
| 173 | + if arg.startswith('--help='): |
| 174 | + search_keyword = arg.split('=', 1)[1] |
| 175 | + |
| 176 | + # List available groups |
| 177 | + if search_keyword == 'listgroup': |
| 178 | + print("\nAvailable argument groups:") |
| 179 | + for group in parser._action_groups: |
| 180 | + if group.title and not group.title.startswith( |
| 181 | + "positional arguments"): |
| 182 | + print(f" - {group.title}") |
| 183 | + if group.description: |
| 184 | + print(" " + group.description.strip()) |
| 185 | + print() |
| 186 | + sys.exit(0) |
| 187 | + |
| 188 | + # For group search |
| 189 | + formatter = parser._get_formatter() |
| 190 | + for group in parser._action_groups: |
| 191 | + if group.title and group.title.lower() == search_keyword.lower( |
| 192 | + ): |
| 193 | + formatter.start_section(group.title) |
| 194 | + formatter.add_text(group.description) |
| 195 | + formatter.add_arguments(group._group_actions) |
| 196 | + formatter.end_section() |
| 197 | + print(formatter.format_help()) |
| 198 | + sys.exit(0) |
| 199 | + |
| 200 | + # For single arg |
| 201 | + matched_actions = [] |
| 202 | + |
| 203 | + for group in parser._action_groups: |
| 204 | + for action in group._group_actions: |
| 205 | + # search option name |
| 206 | + if any(search_keyword.lower() in opt.lower() |
| 207 | + for opt in action.option_strings): |
| 208 | + matched_actions.append(action) |
| 209 | + |
| 210 | + if matched_actions: |
| 211 | + print(f"\nParameters matching '{search_keyword}':\n") |
| 212 | + formatter = parser._get_formatter() |
| 213 | + formatter.add_arguments(matched_actions) |
| 214 | + print(formatter.format_help()) |
| 215 | + sys.exit(0) |
| 216 | + |
| 217 | + print(f"\nNo group or parameter matching '{search_keyword}'") |
| 218 | + print("Tip: use `--help=listgroup` to view all groups.") |
| 219 | + sys.exit(1) |
0 commit comments