feat(client): add exists() method to Client and AsyncClient#2
Open
Missing-Identity wants to merge 1 commit into
Open
feat(client): add exists() method to Client and AsyncClient#2Missing-Identity wants to merge 1 commit into
Missing-Identity wants to merge 1 commit into
Conversation
Add exists(model) that delegates to show() and returns True when the model is present, False on ResponseError with status 404, and re-raises other errors. Includes unit tests for sync/async clients covering success, 404, non-404 errors, and connection failures. Co-authored-by: Unmilan Mukherjee <Missing-Identity@users.noreply.github.com>
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.
Summary
Adds a robust
exists(model: str) -> boolmethod to bothClientandAsyncClient.The method delegates to
show(model)and:Truewhen the model existsFalsewhen aResponseErrorwith status code 404 is raisedResponseErrorand connection errors unchangedMotivation
Checking whether a model is available currently requires calling
show()and manually handling 404 responses.exists()provides a simple, idiomatic helper for this common pattern.Changes
ollama/_client.py: addexists()toClientandAsyncClienttests/test_client.py: add unit tests for sync/async success, 404, non-404 errors, and connection failuresTests
All 8 new
existstests pass (plus 2 existingcreate_blob_existstests matched by the filter).Notes
Built on top of the PR ollama#684 fix for optional
ShowResponse.model_info(already merged on this fork).