From 043dbf437bd2fdee76719b57aae0e6ad01203b9b Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 5 Aug 2026 18:06:20 +0530 Subject: [PATCH 1/2] feat: expose __version__ via importlib.metadata --- ollama/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ollama/__init__.py b/ollama/__init__.py index 92bba280..c0bb46db 100644 --- a/ollama/__init__.py +++ b/ollama/__init__.py @@ -1,4 +1,5 @@ from ollama._client import AsyncClient, Client +from importlib.metadata import version, PackageNotFoundError from ollama._types import ( ChatResponse, EmbeddingsResponse, @@ -57,3 +58,9 @@ ps = _client.ps web_search = _client.web_search web_fetch = _client.web_fetch + + +try: + __version__ = version("ollama") +except PackageNotFoundError: + __version__ = "unknown" \ No newline at end of file From 0bc5c0171d1172bc792404390f1a346bb4ced10a Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 5 Aug 2026 18:37:07 +0530 Subject: [PATCH 2/2] feat: add exists() method to check if model is available locally --- ollama/__init__.py | 1 + ollama/_client.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/ollama/__init__.py b/ollama/__init__.py index c0bb46db..90b66711 100644 --- a/ollama/__init__.py +++ b/ollama/__init__.py @@ -58,6 +58,7 @@ ps = _client.ps web_search = _client.web_search web_fetch = _client.web_fetch +exists = _client.exists try: diff --git a/ollama/_client.py b/ollama/_client.py index 8dfce824..3198c9fe 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -670,6 +670,12 @@ def ps(self) -> ProcessResponse: 'GET', '/api/ps', ) + def exists(self, model: str) -> bool: + try: + self.show(model) + return True + except Exception: + return False def web_search(self, query: str, max_results: int = 3) -> WebSearchResponse: """