mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-23 05:12:26 +00:00
treat NotFound specially
This commit is contained in:
parent
6173d7a308
commit
b4ef2599d9
1 changed files with 13 additions and 6 deletions
|
|
@ -9,7 +9,7 @@ import warnings
|
||||||
from collections.abc import AsyncIterator
|
from collections.abc import AsyncIterator
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from openai import APIConnectionError, AsyncOpenAI, BadRequestError
|
from openai import APIConnectionError, AsyncOpenAI, BadRequestError, NotFoundError
|
||||||
|
|
||||||
from llama_stack.apis.common.content_types import (
|
from llama_stack.apis.common.content_types import (
|
||||||
InterleavedContent,
|
InterleavedContent,
|
||||||
|
|
@ -89,12 +89,19 @@ class NVIDIAInferenceAdapter(Inference, ModelRegistryHelper):
|
||||||
self._config = config
|
self._config = config
|
||||||
|
|
||||||
async def check_model_availability(self, model: str) -> bool:
|
async def check_model_availability(self, model: str) -> bool:
|
||||||
"""Check if a specific model is available from the NVIDIA API."""
|
"""
|
||||||
|
Check if a specific model is available.
|
||||||
|
|
||||||
|
:param model: The model identifier to check.
|
||||||
|
:return: True if the model is available dynamically, False otherwise.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
await self._get_client().models.retrieve(model)
|
await self._client.models.retrieve(model)
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except NotFoundError:
|
||||||
# If we can't retrieve the model, it's not available
|
logger.error(f"Model {model} is not available")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to check model availability: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue