SQLite-backed local Ollama cascade orchestrator.
Project description
granite-sqlite-lfm
SQLite-backed local Ollama cascade orchestrator.
This project runs a local multi-stage model pipeline using Ollama and SQLite. It stores session state, extracted context variables, and conversation history in a local SQLite database, then routes user prompts through a lightweight extraction model, a worker model, and a fallback escalation model when needed.
Features
- SQLite-backed session and context storage
- Full-text searchable conversation history using SQLite FTS5
- Local Ollama model orchestration
- Stage 1 intent and variable extraction
- Stage 2 task execution
- Stage 3 fallback escalation
- Import-safe package structure
- CLI support with custom prompts and database paths
Requirements
-
Python 3.9+
-
Ollama installed and running locally
-
Local Ollama models available:
lfm2.5:230mibm-granite/granite-4.0-h-350m-instructgranite4.1:3b
Installation
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate
On Windows PowerShell:
.venv\Scripts\Activate.ps1
Install the package in editable development mode:
python -m pip install -e ".[dev]"
Usage
Run the package with the default demo prompts:
python -m granite_sqlite_lfm
Or use the console command:
granite-sqlite-lfm
Run a custom prompt:
granite-sqlite-lfm --prompt "Book a conference room for 15 attendees tomorrow at 3 PM."
Use a custom SQLite database path:
granite-sqlite-lfm --db-path ./local_context.db
Use a custom session ID:
granite-sqlite-lfm --session-id enterprise_user_session_101
Run multiple prompts in sequence:
granite-sqlite-lfm \
--prompt "Book a conference room for 15 attendees tomorrow." \
--prompt "Change the attendee count to 45."
Project Structure
granite-sqlite-lfm/
├── pyproject.toml
├── README.md
├── LICENSE
├── .gitignore
├── src/
│ └── granite_sqlite_lfm/
│ ├── __init__.py
│ ├── __main__.py
│ ├── cli.py
│ ├── config.py
│ ├── database.py
│ └── orchestrator.py
├── tests/
│ ├── test_database.py
│ └── test_orchestrator.py
└── examples/
└── demo.py
Development
Install development dependencies:
python -m pip install -e ".[dev]"
Run tests:
pytest
Run Ruff linting:
ruff check .
Build the package:
python -m build
Check distribution artifacts:
twine check dist/*
Publishing
Before publishing, review the package metadata in pyproject.toml, including:
- package name
- author name
- license
- description
- supported Python version
- dependencies
- console script name
Then build and upload:
python -m build
twine check dist/*
twine upload dist/*
Notes
This project depends on a working local Ollama installation. The included tests should avoid real model calls and focus on package importability, SQLite behavior, JSON parsing, and CLI smoke behavior.
The default SQLite database file is:
cascade_context.db
This file is local runtime state and should not be committed to version control.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file granite_sqlite_lfm-0.1.0.tar.gz.
File metadata
- Download URL: granite_sqlite_lfm-0.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfe806473ff42fdc1fc0614fc28f58fcf35983bc8af56476a8b106e8cd6ed254
|
|
| MD5 |
a9301577bb6bd68d4279e9dc8a11926b
|
|
| BLAKE2b-256 |
9a5cb1fd87bc90628d576f57b84261759eb55b998520016dd86ce127e6d9cbfd
|
File details
Details for the file granite_sqlite_lfm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: granite_sqlite_lfm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c7a2777ac39f19985a4eb7cfee39574510fc2858487f70c65baaf4014bdb6a2
|
|
| MD5 |
8699dd39704b9c94a0490069b5054b9b
|
|
| BLAKE2b-256 |
18822cb5560d242e056edc791cd90cc5807437cd4290f4ba42116c663fe314ad
|