|
9 | 9 | from urllib.parse import urljoin
|
10 | 10 |
|
11 | 11 | import httpx
|
12 |
| -from openai import APIConnectionError |
13 | 12 | from openai.types.chat.chat_completion_chunk import (
|
14 | 13 | ChatCompletionChunk as OpenAIChatCompletionChunk,
|
15 | 14 | )
|
@@ -339,16 +338,19 @@ async def register_model(self, model: Model) -> Model:
|
339 | 338 | pass # Ignore statically unknown model, will check live listing
|
340 | 339 | try:
|
341 | 340 | res = self.client.models.list()
|
342 |
| - except APIConnectionError as e: |
343 |
| - raise ValueError( |
344 |
| - f"Failed to connect to vLLM at {self.config.url}. Please check if vLLM is running and accessible at that URL." |
345 |
| - ) from e |
346 |
| - available_models = [m.id async for m in res] |
347 |
| - if model.provider_resource_id not in available_models: |
348 |
| - raise ValueError( |
349 |
| - f"Model {model.provider_resource_id} is not being served by vLLM. " |
350 |
| - f"Available models: {', '.join(available_models)}" |
351 |
| - ) |
| 341 | + available_models = [m.id async for m in res] |
| 342 | + if model.provider_resource_id not in available_models: |
| 343 | + raise ValueError( |
| 344 | + f"Model {model.provider_resource_id} is not being served by vLLM. " |
| 345 | + f"Available models: {', '.join(available_models)}" |
| 346 | + ) |
| 347 | + except Exception as e: |
| 348 | + if self.config.refresh_models: |
| 349 | + raise ValueError(f"Model verification failed: {e}") from e |
| 350 | + # if refresh_models is false, gracefully continue without verification |
| 351 | + log.warning(f"Model verification failed for model {model.model_id} with error {e}") |
| 352 | + log.warning("Continuing without live check (refresh_models=false).") |
| 353 | + |
352 | 354 | return model
|
353 | 355 |
|
354 | 356 | async def _get_params(self, request: ChatCompletionRequest) -> dict:
|
|
0 commit comments