A Python framework for interacting with Ollama and its underlying language models.
- Direct client for interacting with Ollama API
- FastAPI server implementation for enhanced functionality
- Model management (loading, listing)
- Chat completion with streaming support
# Clone the repository
git clone git@github.com:DevItBetter/ollama_project.git
cd ollama-framework
# Create a virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install the package in development mode
pip install -e .Make sure you have Ollama installed and running. You can start it with:
ollama serveFor development with auto-reload:
# Recommended approach (with auto-reload)
python start_server.py --debug
# Alternative approaches
uvicorn ollama_framework.api.main:app --reload
python -m ollama_framework.api.main # If main.py contains server codeCheck if the API is running:
curl http://localhost:8000/
# {"message":"Welcome to the Ollama Framework API"}
curl http://localhost:8000/health
# {"status":"healthy","version":"0.1.0"}List all available models:
curl http://localhost:8000/api/models/
# {"models":[{"name":"llama3","modified_at":"2024-03-16T12:00:00Z"}, ...]}Send a chat message:
curl -X POST http://localhost:8000/api/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llama3",
"messages": [{"role": "user", "content": "Hello, how are you?"}]
}'Once the server is running, view the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc