Metadata-Version: 2.4
Name: granite-sqlite-lfm
Version: 0.1.0
Summary: SQLite-backed local Ollama cascade orchestrator.
Author: Author Name
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ollama
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# 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:230m`
  * `ibm-granite/granite-4.0-h-350m-instruct`
  * `granite4.1:3b`

## Installation

Create and activate a virtual environment:

```bash
python -m venv .venv
source .venv/bin/activate
```

On Windows PowerShell:

```powershell
.venv\Scripts\Activate.ps1
```

Install the package in editable development mode:

```bash
python -m pip install -e ".[dev]"
```

## Usage

Run the package with the default demo prompts:

```bash
python -m granite_sqlite_lfm
```

Or use the console command:

```bash
granite-sqlite-lfm
```

Run a custom prompt:

```bash
granite-sqlite-lfm --prompt "Book a conference room for 15 attendees tomorrow at 3 PM."
```

Use a custom SQLite database path:

```bash
granite-sqlite-lfm --db-path ./local_context.db
```

Use a custom session ID:

```bash
granite-sqlite-lfm --session-id enterprise_user_session_101
```

Run multiple prompts in sequence:

```bash
granite-sqlite-lfm \
  --prompt "Book a conference room for 15 attendees tomorrow." \
  --prompt "Change the attendee count to 45."
```

## Project Structure

```text
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:

```bash
python -m pip install -e ".[dev]"
```

Run tests:

```bash
pytest
```

Run Ruff linting:

```bash
ruff check .
```

Build the package:

```bash
python -m build
```

Check distribution artifacts:

```bash
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:

```bash
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:

```text
cascade_context.db
```

This file is local runtime state and should not be committed to version control.
