ollama-python/examples
2024-12-16 11:34:03 -08:00
..
async-chat.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
async-generate.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
async-structured-outputs.py Structured outputs support with examples (#354) 2024-12-05 15:40:49 -08:00
async-tools.py Improve tool example to showcase chatting (#352) 2024-11-29 20:34:19 -08:00
chat-stream.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
chat-with-history.py Fix chat-with-history.py example (#337) 2024-11-24 10:49:46 -08:00
chat.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
create.py Examples refactor (#329) 2024-11-21 15:14:59 -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 Examples refactor (#329) 2024-11-21 15:14:59 -08:00
generate.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
list.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
multimodal-chat.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
multimodal-generate.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
ps.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
pull.py Examples refactor (#329) 2024-11-21 15:14:59 -08:00
README.md Add tests + cleanup 2024-12-16 11:34:03 -08:00
structured-outputs-image.py fix: structured outputs example (#364) 2024-12-07 20:01:21 -08:00
structured-outputs.py Structured outputs support with examples (#354) 2024-12-05 15:40:49 -08:00
tokenization.py Add tests + cleanup 2024-12-16 11:34:03 -08:00
tools.py Improve tool example to showcase chatting (#352) 2024-11-29 20:34:19 -08:00

Running Examples

Run the examples in this directory with:

# Run example
python3 examples/<example>.py

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

Tokenization - Tokenize and detokenize text with a model

Ollama List - List all downloaded models and their properties

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

python create.py <model> <modelfile>

See ollama/docs/modelfile.md for more information on the Modelfile format.

Ollama Embed - Generate embeddings with a model