ollama-python/examples
JRinaldi 5d7c63fae1
Some checks failed
test / test (push) Has been cancelled
test / lint (push) Has been cancelled
types: add capabilities to show response. (#511)
2025-05-14 19:27:48 -07:00
..
async-chat.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
async-generate.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
async-structured-outputs.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
async-tools.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
chat-stream.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
chat-with-history.py Merge pull request #445 from ollama/mxyng/hatch 2025-05-06 11:03:28 -07:00
chat.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
create.py client: improve error messaging on connection failure (#398) 2025-01-16 13:55:17 -08:00
embed.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
fill-in-middle.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
generate-stream.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
generate.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
list.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
multimodal-chat.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
multimodal-generate.py Merge pull request #445 from ollama/mxyng/hatch 2025-05-06 11:03:28 -07:00
ps.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
pull.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
README.md types: add capabilities to show response. (#511) 2025-05-14 19:27:48 -07:00
show.py types: add capabilities to show response. (#511) 2025-05-14 19:27:48 -07:00
structured-outputs-image.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
structured-outputs.py chore: bump ruff and ensure imports are sorted (#385) 2025-01-14 16:34:16 -08:00
tools.py examples: update tools.py to handle type casting from tool arguments (#443) 2025-02-14 09:50:47 -08:00

Running Examples

Run the examples in this directory with:

# Run example
python3 examples/<example>.py

See ollama/docs/api.md for full API documentation

Chat - Chat with a model

Generate - Generate text with a model

Tools/Function Calling - Call a function with a model

Multimodal with Images - Chat with a multimodal (image chat) model

Structured Outputs - Generate structured outputs with a model

Ollama List - List all downloaded models and their properties

Ollama Show - Display model properties and capabilities

Ollama ps - Show model status with CPU/GPU usage

Ollama Pull - Pull a model from Ollama

Requirement: pip install tqdm

Ollama Create - Create a model from a Modelfile

Ollama Embed - Generate embeddings with a model