|
5 | 5 |
|
6 | 6 | logger = logging.getLogger(__name__) |
7 | 7 |
|
| 8 | +_RESERVED_GENERATE_PATHS = { |
| 9 | + "/generate", |
| 10 | + "/inference/v1/generate", |
| 11 | + "/v1/chat/completions", |
| 12 | + "/v1/completions", |
| 13 | + "/rerank", |
| 14 | + "/v1/rerank", |
| 15 | + "/v1/responses", |
| 16 | + "/v1/embeddings", |
| 17 | + "/liveness", |
| 18 | + "/readiness", |
| 19 | + "/health", |
| 20 | + "/health_generate", |
| 21 | + "/v1/models", |
| 22 | + "/get_model_info", |
| 23 | + "/get_server_info", |
| 24 | + "/add_worker", |
| 25 | + "/remove_worker", |
| 26 | + "/list_workers", |
| 27 | + "/flush_cache", |
| 28 | + "/get_loads", |
| 29 | + "/workers", |
| 30 | +} |
| 31 | + |
8 | 32 |
|
9 | 33 | @dataclasses.dataclass |
10 | 34 | class RouterArgs: |
@@ -89,6 +113,8 @@ class RouterArgs: |
89 | 113 | cb_timeout_duration_secs: int = 60 |
90 | 114 | cb_window_duration_secs: int = 120 |
91 | 115 | disable_circuit_breaker: bool = False |
| 116 | + # Additional typed inference-generate routes |
| 117 | + extra_generate_paths: List[str] = dataclasses.field(default_factory=list) |
92 | 118 |
|
93 | 119 | @staticmethod |
94 | 120 | def add_cli_args( |
@@ -128,6 +154,13 @@ def add_cli_args( |
128 | 154 | default=[], |
129 | 155 | help="List of worker URLs (e.g., http://worker1:8000 http://worker2:8000)", |
130 | 156 | ) |
| 157 | + parser.add_argument( |
| 158 | + f"--{prefix}extra-generate-paths", |
| 159 | + type=str, |
| 160 | + nargs="*", |
| 161 | + default=[], |
| 162 | + help="Additional HTTP paths using the inference-generate request schema", |
| 163 | + ) |
131 | 164 |
|
132 | 165 | # Routing policy configuration |
133 | 166 | parser.add_argument( |
@@ -518,6 +551,19 @@ def from_cli_args( |
518 | 551 | return cls(**args_dict) |
519 | 552 |
|
520 | 553 | def _validate_router_args(self): |
| 554 | + if len(set(self.extra_generate_paths)) != len(self.extra_generate_paths): |
| 555 | + raise ValueError("extra_generate_paths must not contain duplicates") |
| 556 | + for path in self.extra_generate_paths: |
| 557 | + if ( |
| 558 | + len(path) < 2 |
| 559 | + or not path.startswith("/") |
| 560 | + or path in _RESERVED_GENERATE_PATHS |
| 561 | + or path.startswith("/v1/responses/") |
| 562 | + or path.startswith("/workers/") |
| 563 | + or any(character in path for character in "?#{}*") |
| 564 | + ): |
| 565 | + raise ValueError(f"invalid extra generate path: {path}") |
| 566 | + |
521 | 567 | # Validate configuration based on mode |
522 | 568 | if self.vllm_pd_disaggregation: |
523 | 569 | # Validate PD configuration - skip URL requirements if using service discovery |
|
0 commit comments