Ollama Integration¶
ModelDock's first shipped runtime is Ollama. This guide covers the full integration.
Prerequisites¶
- Python 3.9–3.12
- A local Ollama install with the daemon running (
ollama serve)
Load a Model¶
import modeldock as md
client = md.load("llama3") # auto-installs if missing
client = md.load("llama3", backend="ollama") # explicit backend
load is idempotent — calling it again for an installed model is instant.
Discover and Inspect¶
md.list() # browse the catalog
md.search("coding") # search by name / capability / category
md.installed() # models already local (ModelRef list)
md.info("qwen3") # sizes, capabilities, variants, installed tags
md.categories() # available categories
md.recommend(task="vision") # guided pick
md.installed() and md.info() work even for models not in the bundled catalog, as long as they're installed in Ollama.
Install Explicitly¶
md.install("llama3") # single model
md.install("llama3", backend="ollama")
md.install_category("coding") # bulk install recommended models
Run Completions / REPL¶
# Single completion
result = md.run("llama3", prompt="Explain semver in one sentence.")
print(result.text)
# Interactive REPL (reads stdin until you exit)
md.run("llama3")
Pass Ollama generation options:
Update and Remove¶
md.update("llama3", confirm=True) # removes then re-downloads — requires confirm
md.remove("llama3") # uninstall
md.verify("llama3") # integrity check -> bool
Destructive Operation
update() deletes and re-pulls. It requires confirm=True and refuses cloud/subscription models.
Cache Management¶
md.cache.status() # list cache entries
md.cache.path() # real cache directory
md.cache.clean() # safe: removes only corrupt/partial entries
md.cache.clean(force=True) # wipes everything
Configuration¶
Or build an explicit manager:
Cloud / Subscription Models¶
Some catalog entries are cloud/subscription models (tag contains cloud). These cannot be installed, run, or removed through a local Ollama runtime:
md.remove("glm-5.2:cloud") # -> DownloadError: cloud/subscription model ...
md.update("glm-5.2:cloud", confirm=True) # -> DownloadError (rejected)
Runtime Status¶
device is Device.GPU, Device.CPU, or Device.UNKNOWN.