Metadata-Version: 2.4
Name: string_therapy
Version: 0.0.1
Summary: JWT-gated LLM controller that routes messages over a PostgreSQL + Apache AGE graph and forwards to downstream HTTP endpoints
Author-email: Alex <alixjcob559@gmail.com>
License: Apache-2.0
Project-URL: Repository, https://github.com/alix559/string_therapy
Project-URL: Documentation, https://alix559.github.io/string_therapy/
Keywords: nbdev,router,fasthtml,apache-age,lisette
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-fasthtml<0.15,>=0.14.6
Requires-Dist: httpx<0.29,>=0.28.1
Requires-Dist: python-dotenv<2,>=1.2.2
Requires-Dist: psycopg[binary]<4,>=3.3.4
Requires-Dist: PyJWT<3,>=2.8
Requires-Dist: lisette<0.2,>=0.1.35
Provides-Extra: dev
Requires-Dist: pytest<9,>=8; extra == "dev"
Requires-Dist: nbdev<4,>=3.2.2; extra == "dev"
Dynamic: license-file

# string_therapy

> JWT-gated LLM controller that routes messages over PostgreSQL + Apache AGE and forwards to downstream HTTP endpoints

`string_therapy` is a FastHTML service: Lisette picks a category/endpoint from an AGE routing graph (ACL-filtered by JWT), then `forward_tool` calls your downstream HTTP APIs.

## Quickstart

### Install

```sh
pip install -e .
# or: pip install git+https://github.com/alix559/string_therapy.git
```

### Configure

Copy `.env.example` to `.env` and set at least:

- `ROUTER_DATABASE_URL` — Postgres DSN with Apache AGE available
- `LISETTE_MODEL` + `LISETTE_API_KEY` (or `OPENAI_API_KEY`)
- `JWT_SECRET` (or `JWT_AUTH_DISABLED=true` for local dev)

### Schema → seed → serve

```sh
string-therapy-ensure-schema
string-therapy-seed --graph examples/router_graph.json
string-therapy-serve
```

Or in Python:

```python
from string_therapy import ensure_schema, seed_router_db, create_app, serve_controller

ensure_schema()
seed_router_db('examples/router_graph.json')
serve_controller()  # or: app = create_app()
```

### Call the API

```sh
curl -s http://127.0.0.1:5011/health

curl -s http://127.0.0.1:5011/controller \
  -H 'Authorization: Bearer <jwt>' \
  -H 'Content-Type: application/json' \
  -d '{"message": "run a sales report"}'
```

JWT claims: `sub` (required), optional `roles` / `groups`. Those map to ACL principals like `role:analyst`.

### Router graph JSON

See `examples/router_graph.json` (also packaged under `string_therapy/examples/`). Nodes are categories or endpoints; edges are `SERVES`; optional `acl` rows set `(node_id, principal, permission)`.

### Example notebook

Walk through the library interactively:

```sh
jupyter notebook examples/getting_started.ipynb
```

## Developer Guide

This project uses [nbdev](https://nbdev.fast.ai). Edit notebooks under `nbs/`, then:

```sh
pip install -e ".[dev]"
nbdev_prepare
pytest -q
```

## Documentation

- Docs: https://alix559.github.io/string_therapy/
- Repo: https://github.com/alix559/string_therapy
