.. Ollama Toolkit documentation master file
Ollama Toolkit Documentationο
Welcome to the Ollama Toolkit documentationβwhere precision meets possibility. This Python client provides a comprehensive interface to interact with Ollama, a framework for running large language models locally with exceptional efficiency.
Overviewο
Ollama Toolkit gives you programmatic access to:
Text generation with surgical precision
Chat completion engineered for natural flow
Embedding creation with mathematical elegance
Model management (listing, pulling, copying, deleting) with controlled recursion
Async operations for high-velocity performance applications
Robust error handling with intuitive fallback mechanisms
Automatic Ollama installation and startup with zero friction
Key Featuresο
π Complete API Coverage: Support for all Ollama endpointsβnothing missing, nothing extra
π Recursive Async Support: Both synchronous and asynchronous interfaces that build upon each other
π§ Structurally Perfect CLI: Powerful command-line tools with intuitive architecture
π Zero-Friction Auto-Installation: Install and start Ollama with mathematically minimal steps
πͺ Self-Aware Error Handling: Comprehensive error types that explain precisely what went wrong
π Velocity-Optimized Embeddings: Create and manipulate embeddings with maximum efficiency
π§ͺ Recursively Refined Testing: Every function proven robust through iterative improvement
π Version-Aware: Full compatibility with Ollama 0.1.8 and beyond
Getting Startedο
# This implementation follows Eidosian principles of contextual integrity and precision
from ollama_toolkit import OllamaClient, __version__
from ollama_toolkit.utils.common import ensure_ollama_running
# Display toolkit version β foundational awareness
print(f"Ollama Toolkit version: {__version__}") # Should be 0.1.8
# Ensure Ollama is installed and running β structurally sound foundation
is_running, message = ensure_ollama_running()
if not is_running:
print(f"Error: {message}")
exit(1)
print(f"Ollama status: {message}")
# Initialize the client with optimal timeout
client = OllamaClient(timeout=600) # 10-minute timeout
# Check Ollama server version β recommended minimum is v0.1.11
version = client.get_version()
print(f"Connected to Ollama server version: {version.get('version', 'unknown')}")
# List available models β structural awareness
models = client.list_models()
model_names = [model["name"] for model in models.get("models", [])]
print(f"Available models: {model_names}")
# Generate text with precision and flow
if model_names: # Use first available model if any exist
model_name = model_names[0]
print("\nGenerating a short test response...")
response = client.generate(model=model_name, prompt="Say hello!", stream=False)
print(f"\nResponse: {response.get('response', 'No response generated')}")
else:
print("No models available. Use client.pull_model() to download a model.")
Installation Guideο
Install via PyPI:
pip install ollama-toolkit==0.1.8
Or install locally in editable mode:
pip install -e /path/to/ollama_toolkit
Documentation Contentsο
π Getting Started
π οΈ Core Documentation
π Features & Capabilities
π§ Guides & References
Examplesο
Check out these practical examples:
Basic Usage β Precision in simplicity
Generate Text β Flow like a river
Chat Completion β Universal yet personal
Embeddings β Mathematical elegance
Model Management β Structural control
Error Handling β Self-aware resilience
All examples can be run via:
python -m ollama_toolkit.examples.<example_file>
(e.g. python -m ollama_toolkit.examples.quickstart
).
Version Historyο
0.1.8 (Current) - Enhanced embedding operations, improved async support, expanded CLI
0.1.7 - Added comprehensive error handling and model fallbacks
0.1.6 - Introduced caching and optimization for embeddings
0.1.5 - Initial public release with basic functionality
Licenseο
This project is licensed under the MIT License - see the LICENSE file for details.
Project Repositoryο
Find the complete source code on GitHub: https://github.com/Ace1928/ollama_toolkit