feat: add exists() method to check if model is available locally

This commit is contained in:
Pawansingh3889 2026-04-05 16:40:29 +01:00
parent dbccf192ac
commit b82953af44

View File

@ -664,6 +664,16 @@ class Client(BaseClient):
).model_dump(exclude_none=True),
)
def exists(self, model: str) -> bool:
"""Check if a model is available locally."""
try:
self.show(model)
return True
except ResponseError:
return False
def ps(self) -> ProcessResponse:
return self._request(
ProcessResponse,
@ -1305,6 +1315,16 @@ class AsyncClient(BaseClient):
).model_dump(exclude_none=True),
)
async def exists(self, model: str) -> bool:
"""Check if a model is available locally."""
try:
await self.show(model)
return True
except ResponseError:
return False
async def ps(self) -> ProcessResponse:
return await self._request(
ProcessResponse,