fix: add __version__ attribute to package

The ollama package was missing a __version__ attribute, causing
AttributeError when users try to access ollama.__version__.

This fix adds __version__ using importlib.metadata.version() which
reads the version from package metadata (set by hatch-vcs from git
tags). Falls back to '0.0.0' if metadata is unavailable.

Fixes #623

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Abdelhadi Salmaoui 2026-03-25 14:54:01 +01:00
parent dbccf192ac
commit c6199e3eea
No known key found for this signature in database
GPG Key ID: 53E7D89B27AF9E04

View File

@ -1,3 +1,5 @@
from importlib.metadata import version as _get_version
from ollama._client import AsyncClient, Client
from ollama._types import (
ChatResponse,
@ -19,6 +21,11 @@ from ollama._types import (
WebSearchResponse,
)
try:
__version__ = _get_version('ollama')
except Exception:
__version__ = '0.0.0'
__all__ = [
'AsyncClient',
'ChatResponse',
@ -39,6 +46,7 @@ __all__ = [
'Tool',
'WebFetchResponse',
'WebSearchResponse',
'__version__',
]
_client = Client()