Skip to content

feat: add exists() method and fix ShowResponse for cloud models (clos…#672

Open
shivanireddyk wants to merge 1 commit into
ollama:mainfrom
shivanireddyk:feat/exists-method
Open

feat: add exists() method and fix ShowResponse for cloud models (clos…#672
shivanireddyk wants to merge 1 commit into
ollama:mainfrom
shivanireddyk:feat/exists-method

Conversation

@shivanireddyk
Copy link
Copy Markdown

…es #640, closes #607)
Closes #640
Closes #607

Changes

New: ollama.exists(model)

A clean boolean check for whether a model is available locally —
no more catching exceptions for control flow.

# Before (ugly)
try:
    ollama.show("llama3.2")
except ollama.ResponseError:
    ollama.pull("llama3.2")

# After (clean)
if not ollama.exists("llama3.2"):
    ollama.pull("llama3.2")

Available on both Client and AsyncClient.

Bug fix: ShowResponse crash on cloud models (#607)

model_info was declared as required by Pydantic even though it was
typed Optional. Cloud models like glm-4.7:cloud don't return
model_info, causing a hard ValidationError. Fixed by adding
default=None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant