|
9 | 9 | from urllib.parse import urljoin
|
10 | 10 |
|
11 | 11 | import httpx
|
12 |
| -from openai import APIConnectionError, AsyncOpenAI |
| 12 | +from openai import AsyncOpenAI |
13 | 13 | from openai.types.chat.chat_completion_chunk import (
|
14 | 14 | ChatCompletionChunk as OpenAIChatCompletionChunk,
|
15 | 15 | )
|
@@ -430,16 +430,19 @@ async def register_model(self, model: Model) -> Model:
|
430 | 430 | pass # Ignore statically unknown model, will check live listing
|
431 | 431 | try:
|
432 | 432 | res = self.client.models.list()
|
433 |
| - except APIConnectionError as e: |
434 |
| - raise ValueError( |
435 |
| - f"Failed to connect to vLLM at {self.config.url}. Please check if vLLM is running and accessible at that URL." |
436 |
| - ) from e |
437 |
| - available_models = [m.id async for m in res] |
438 |
| - if model.provider_resource_id not in available_models: |
439 |
| - raise ValueError( |
440 |
| - f"Model {model.provider_resource_id} is not being served by vLLM. " |
441 |
| - f"Available models: {', '.join(available_models)}" |
442 |
| - ) |
| 433 | + available_models = [m.id async for m in res] |
| 434 | + if model.provider_resource_id not in available_models: |
| 435 | + raise ValueError( |
| 436 | + f"Model {model.provider_resource_id} is not being served by vLLM. " |
| 437 | + f"Available models: {', '.join(available_models)}" |
| 438 | + ) |
| 439 | + except Exception as e: |
| 440 | + if self.config.refresh_models: |
| 441 | + raise ValueError(f"Model verification failed: {e}") from e |
| 442 | + # if refresh_models is false, gracefully continue without verification |
| 443 | + log.warning(f"Model verification failed for model {model.model_id} with error {e}") |
| 444 | + log.warning("Continuing without live check (refresh_models=false).") |
| 445 | + |
443 | 446 | return model
|
444 | 447 |
|
445 | 448 | async def _get_params(self, request: ChatCompletionRequest) -> dict:
|
|
0 commit comments