notebook-ollama
Recipe card from the charly-jupyter plugin (Images — the deployable catalog).
notebook-ollama – Ollama integration notebook data candy
Section titled “notebook-ollama – Ollama integration notebook data candy”Candy Properties
Section titled “Candy Properties”| Property | Value |
|---|---|
| Dependencies | (none) |
| Packages | (none) |
| Services | (none) |
| Volumes | workspace -> /workspace (from jupyter) |
| Data | data/ollama -> workspace volume, dest: ollama |
| Install files | (none) |
How It Works
Section titled “How It Works”This is a data candy — it uses the data: field in charly.yml to map a directory of notebooks to a named volume with a subdirectory destination:
info: "Ollama integration notebook collection"
data: - src: data/ollama volume: workspace dest: ollamaAt build time, the contents of data/ollama/ are staged into /data/workspace/ollama/ inside the box.
At deploy time, charly config or charly update copies the staged data into the workspace volume at <workspace>/ollama/. The dest: ollama field places the notebooks in a subdirectory rather than the volume root.
Included Notebooks
Section titled “Included Notebooks”6 Jupyter notebooks covering different Ollama client libraries:
| Notebook | Library | Features |
|---|---|---|
00_Ollama_Requests.ipynb |
requests |
Raw REST API: list, show, generate, chat, stream, embed, copy, delete |
01_Ollama_GPU.ipynb |
requests |
GPU verification: nvidia-smi, inference metrics, VRAM monitoring |
02_Ollama_OpenAI.ipynb |
openai |
OpenAI-compatible API: completions, chat, multi-turn, stream, embed |
03_Ollama_Library.ipynb |
ollama |
Native Python library: all API operations + model management |
04_Ollama_HuggingFace.ipynb |
ollama |
HuggingFace GGUF model import, verification, inference |
05_Ollama_Anthropic.ipynb |
anthropic |
Anthropic-compatible API: chat, system prompts, streaming, tool calling, vision |
Manifest: notebooks.yaml — structured catalog with title, description, and ordering.
Network Connectivity
Section titled “Network Connectivity”The notebooks default to http://localhost:11434 for the Ollama API endpoint. Each notebook reads:
OLLAMA_HOST = os.getenv("OLLAMA_HOST", "http://localhost:11434")When the ollama box is deployed via charly config ollama, its env_provide automatically injects OLLAMA_HOST=http://charly-ollama:11434 into the global charly.yml env. Any container configured after ollama (or reconfigured with --update-all) automatically gets the correct Ollama endpoint — no manual environment setup needed.
Setup:
charly config ollama --update-all # deploys ollama + propagates OLLAMA_HOST to allcharly start ollamacharly start jupyter-ml-notebook # OLLAMA_HOST already set via env_provideBoth containers must be on the same charly Podman network for DNS resolution to work.
See /charly-core:charly-config for --update-all and /charly-ollama:ollama for env_provide details.
Notebook Compatibility Notes
Section titled “Notebook Compatibility Notes”ollama Python library env var gotcha
Section titled “ollama Python library env var gotcha”The ollama Python library creates its HTTP client at import time by reading OLLAMA_HOST from os.environ. Module-level functions (ollama.list(), ollama.generate(), etc.) are bound methods on this cached client. Simply setting a Python variable doesn’t propagate to the library.
The notebooks use this pattern to handle both fresh kernels and re-runs:
import osOLLAMA_HOST = os.getenv("OLLAMA_HOST", "http://localhost:11434")os.environ["OLLAMA_HOST"] = OLLAMA_HOST
import ollamaimport importlib; importlib.reload(ollama) # Rebinds module functionsPydantic model changes (ollama >= 0.4)
Section titled “Pydantic model changes (ollama >= 0.4)”The newer ollama library returns Pydantic models, not dicts. Model names are accessed via .model attribute (not ["name"]), and the list is .models (not .get("models", [])):
# Old (dict access)model_names = [m.get("model", "") for m in models.get("models", [])]
# New (Pydantic attribute access)model_names = [m.model for m in models.models]Default models
Section titled “Default models”- 5 notebooks use
llama3.2:latest(3.2B, Q4_K_M) ollama_anthropic.ipynbusesministral-3:3b-instruct-2512-q4_K_M
Pull models before running: charly shell ollama -c "ollama pull llama3.2"
jupyter-ml-notebook: candy: - jupyter-ml - notebook-templates - notebook-finetuning - notebook-ollama # ... other candies# Deploy and start both servicescharly config ollama && charly start ollamacharly config jupyter-ml-notebook && charly start jupyter-ml-notebook
# Pull a model, then open notebookscharly shell ollama -c "ollama pull llama3.2"# Open http://localhost:8888 -> navigate to ollama/Used In Boxes
Section titled “Used In Boxes”Related Skills
Section titled “Related Skills”/charly-image:layer— data field documentation and candy authoring rules/charly-core:charly-config— data provisioning duringcharly configsetup/charly-core:deploy— volume backing configuration/charly-jupyter:notebook-finetuning— sibling data candy pattern (Unsloth fine-tuning notebooks)/charly-jupyter:notebook-templates— sibling data candy pattern (starter notebooks)/charly-ollama:ollama— the Ollama binary candy (server side)/charly-ollama:ollama— the standalone Ollama box (must be running for notebooks to connect)/charly-jupyter:jupyter-ml-notebook— the box that includes this candy
When to Use This Skill
Section titled “When to Use This Skill”Use when the user asks about:
- The notebook-ollama candy or its contents
- Ollama API tutorial notebooks or integration examples
- How Jupyter notebooks connect to a separate Ollama container
- The
ollamaPython library env var or Pydantic API gotchas - Which client libraries and API features are covered
Related
Section titled “Related”/charly-check:check— declarative testing (check:block,charly check box,charly check live)