Skip to content

feat: add client.exists() to check if a model is available locally#645

Closed
CyberRaccoonTeam wants to merge 1 commit intoollama:mainfrom
CyberRaccoonTeam:feat/client-exists-640
Closed

feat: add client.exists() to check if a model is available locally#645
CyberRaccoonTeam wants to merge 1 commit intoollama:mainfrom
CyberRaccoonTeam:feat/client-exists-640

Conversation

@CyberRaccoonTeam
Copy link
Copy Markdown

Summary

Implements #640 — adds exists() method to Client and AsyncClient that checks if a specific model is already pulled locally.

Changes

  • Added Client.exists(model: str) -> bool — wraps list() to check for a model by name
  • Added AsyncClient.exists(model: str) -> bool — async version
  • Added top-level ollama.exists() convenience function
  • 5 tests covering: found, not found, empty list, async variants

Usage

import ollama

# Check before pulling
if not ollama.exists("llama3.1:8b"):
    ollama.pull("llama3.1:8b")

# Or with client
client = ollama.Client()
if client.exists("qwen2.5:latest"):
    response = client.chat("qwen2.5:latest", messages=[...])

Testing

5 tests — all passing
- test_client_exists_true
- test_client_exists_false  
- test_client_exists_empty_list
- test_async_client_exists_true
- test_async_client_exists_false

Implements #640 — adds exists() method to Client and AsyncClient that
wraps list() to check if a specific model is pulled locally.

Usage:
  client.exists('llama3.1:8b')  # True or False

Also exposed as top-level ollama.exists() convenience function.
@CyberRaccoonTeam CyberRaccoonTeam closed this by deleting the head repository Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant