mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-23 23:13:56 +00:00
query_available_models() -> list[str] -> check_model_availability(model) -> bool
This commit is contained in:
parent
c2ab8988e6
commit
f69ae45127
2 changed files with 10 additions and 5 deletions
|
|
@ -89,9 +89,14 @@ class NVIDIAInferenceAdapter(Inference, ModelRegistryHelper):
|
|||
|
||||
self._config = config
|
||||
|
||||
async def query_available_models(self) -> list[str]:
|
||||
"""Query available models from the NVIDIA API."""
|
||||
return [model.id async for model in self._get_client().models.list()]
|
||||
async def check_model_availability(self, model: str) -> bool:
|
||||
"""Check if a specific model is available from the NVIDIA API."""
|
||||
try:
|
||||
await self._get_client().models.retrieve(model)
|
||||
return True
|
||||
except Exception:
|
||||
# If we can't retrieve the model, it's not available
|
||||
return False
|
||||
|
||||
@lru_cache # noqa: B019
|
||||
def _get_client(self, provider_model_id: str | None = None) -> AsyncOpenAI:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue