From 043dbf437bd2fdee76719b57aae0e6ad01203b9b Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 5 Aug 2026 18:06:20 +0530 Subject: [PATCH 1/3] 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/3] 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: """ From 27433250027f0fa017c5d87acae8f2b6beace638 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 6 Aug 2026 11:21:06 +0530 Subject: [PATCH 3/3] fix: make model_info optional in ShowResponse to handle cloud models --- ollama/_types.py | 2 +- tests/test_show.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/test_show.py diff --git a/ollama/_types.py b/ollama/_types.py index 96529d63..2afb8ee2 100644 --- a/ollama/_types.py +++ b/ollama/_types.py @@ -572,7 +572,7 @@ class ShowResponse(SubscriptableBaseModel): details: Optional[ModelDetails] = None - modelinfo: Optional[Mapping[str, Any]] = Field(alias='model_info') + modelinfo: Optional[Mapping[str, Any]] = Field(default=None, alias='model_info') parameters: Optional[str] = None diff --git a/tests/test_show.py b/tests/test_show.py new file mode 100644 index 00000000..8f7433d0 --- /dev/null +++ b/tests/test_show.py @@ -0,0 +1,13 @@ +import sys +sys.path.insert(0, '.') # force Python to use local folder first + +from ollama._types import ShowResponse + +test_data = { + "template": "test template", + "details": None, +} + +response = ShowResponse(**test_data) +print(f"modelinfo: {response.modelinfo}") +print("✓ Fix works — no ValidationError") \ No newline at end of file