diff --git a/ollama/_client.py b/ollama/_client.py index 18cb0fb4..81b2d12c 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -664,6 +664,16 @@ def show(self, model: str) -> ShowResponse: ).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 @@ async def show(self, model: str) -> ShowResponse: ).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,