feat: add helpers to expose package version and server version API #647
Open
ravivarmanr26 wants to merge 2 commits intoollama:mainfrom
Open
feat: add helpers to expose package version and server version API #647ravivarmanr26 wants to merge 2 commits intoollama:mainfrom
ravivarmanr26 wants to merge 2 commits intoollama:mainfrom
Conversation
Adds: - ollama.__version__ for the installed package version - .version() method on Client and AsyncClient to fetch /api/version Includes tests. Closes ollama#646
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #646
There was no clean way to check the installed package version or query the running Ollama server version from Python without resorting to workarounds like parsing package metadata manually or catching exceptions.
This PR exposes two things:
ollama.__version__: already existed internally in_client.pyfor the User-Agent header, just not exported. Now re-exported via__init__.py.ollama.version(): top-level alias forClient.version(), which callsGET /api/versionand returns the version string.AsyncClient.version()added for completeness.Usage
Changes
ollama/__init__.py: exports__version__and wiresversionas a top-level aliasollama/_client.py: addsversion()toClientandAsyncClienttests/test_client.py: 4 new tests: package attribute check, sync/async , missing field edge caseTests
All tests pass locally.
Command used:
pytest tests/test_client.pyResult :