Commit Graph
7 Commits
Author SHA1 Message Date
westfarnandCursor f0b8973334 Depend on unstructured[xlsx] so spreadsheet ingest has required deps.
CI / test (pull_request) Successful in 11s
Unit Tests / test (pull_request) Successful in 10s
Bare unstructured omits networkx/msoffcrypto/xlrd; xlsx partition then
crashes reindex. The [xlsx] extra is the supported install path.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 13:56:21 -05:00
westfarn 8ff3ad83d1 Fix reindex_embeddings crash: add networkx for Unstructured xlsx.
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 10s
unstructured.partition.xlsx imports networkx; without it reindex dies
mid-run after clearing Chroma. Also skip per-document ingest failures
so one bad file cannot abort the whole rebuild.
2026-08-02 13:54:58 -05:00
westfarn d8f5b8ebf2 Always-on grounded retrieval + role-scoped Ollama models (#62 Phases 1–3) (#65)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 10s
Deploy Beta / docker (push) Successful in 30s
Deploy Beta / deploy-beta (push) Successful in 6m49s
## Summary
- Closes Phases 1–3 of [#62](#62) (Phase 4 eval harness left for a follow-up).
- **Accuracy:** Retrieval is decided every turn (`GroundingDecider`, fails open). `FAST` no longer skips search — it only selects `OLLAMA_MODEL_FAST`. Search failures surface an explicit error instead of hallucinating from parametric memory.
- **Search:** Pluggable `services/search/` with **SearxNG primary** + DDGS failover, ranking/dedupe/rumour filtering, numbered dated source blocks, citations persisted on `Prompt.citations` and emitted as `{"v":1,"type":"citations",...}` after stream end.
- **Models:** Role-scoped `OLLAMA_MODEL_THINKING` / `_FAST` / `_UTILITY` / `OLLAMA_EMBED_MODEL=nomic-embed-text`, configurable `num_ctx`, real model name on `PromptMetric`, `reindex_embeddings` management command + loud embedding-dimension mismatch.

## SearxNG (ops)
See README **SearxNG** section. Short version: run `searxng/searxng` on the GPU host, enable `json` in `settings.yml`, set `SEARXNG_BASE_URL=http://10.0.0.128:8080` in prod/beta secrets, open `:8080` on the LAN firewall like Ollama.

## Test plan
- [x] `SKIP_RAG_INIT=1 python manage.py test chat_backend.tests` — 442 OK (6 skipped)
- [ ] Deploy beta with updated secrets (`OLLAMA_MODEL_*`, `OLLAMA_EMBED_MODEL=nomic-embed-text`, `SEARXNG_BASE_URL`)
- [ ] After embed change: `python manage.py reindex_embeddings`
- [ ] Verify `did Taylor Swift get married` in FAST and THINKING returns grounded answer with citations frame
- [ ] Kill SearxNG and confirm factual turns return search_unavailable (not Joe Alwyn hallucination); non-factual chat still worksReviewed-on: #65
2026-08-02 11:46:02 -07:00
westfarn ad44359804 Add finance app with Stripe Checkout subscriptions (#21) (#23)
Unit Tests / test (push) Successful in 10s
## Summary
- Closes #21 — new Django `finance` app with Stripe as payment provider
- Subscription price defaults to **$10 USD / month** via `SUBSCRIPTION_PRICE_AMOUNT_CENTS = 1000` in `settings.py` (env-overridable)
- Persists **Invoice** and **Payment** rows; both registered in Django admin (with payment inline on invoices)
- Checkout Session API redirects users to Stripe hosted payment; webhook verifies signatures and upserts ledger idempotently

## API
- `POST /api/finance/checkout/` — JWT auth → `{ checkout_url, session_id }`
- `GET /api/finance/invoices/` / `GET /api/finance/payments/` — own records
- `POST /api/finance/webhooks/stripe/` — Stripe signature-verified webhook

## Config
Documented in `.env.example` / `.env.prod.example`:
`STRIPE_SECRET_KEY`, `STRIPE_PUBLISHABLE_KEY`, `STRIPE_WEBHOOK_SECRET`, optional `STRIPE_PRICE_ID`, `FRONTEND_BASE_URL`

## Test plan
- [x] `uv run python manage.py test finance` (17 tests)
- [ ] Set Stripe test keys locally; create checkout session; complete payment in Stripe test mode
- [ ] Confirm Invoice/Payment appear in `/admin/`
- [ ] Point Stripe webhook to `/api/finance/webhooks/stripe/` and verify `checkout.session.completed` / `invoice.paid`Reviewed-on: #23
2026-07-26 17:35:06 -07:00
westfarn 85637e3db6 Unpin langgraph stack; upgrade langchain-core instead (#14)
Unit Tests / test (push) Successful in 9s
Closes #10

## Summary
- Remove force-pins on `langgraph==1.0.4` / `langgraph-checkpoint==3.0.1` / `langgraph-prebuilt==1.0.5` / `langgraph-sdk==0.2.14`
- Upgrade langchain stack so current langgraph-checkpoint (4.x) works with `Reviver(allowed_objects=...)`
- Keep direct `langgraph>=1.2.5,<1.3.0` (matches langchain 1.3.x); checkpoint/prebuilt/sdk resolve transitively
- Adapt `BaseMessage.text()` → `.text` property for langchain-core 1.5.x

## Resolved versions (uv.lock)
| Package | Before | After |
|---|---|---|
| langchain-core | 1.1.1 | 1.5.1 |
| langchain | 1.1.2 | 1.3.14 |
| langgraph | 1.0.4 | 1.2.9 |
| langgraph-checkpoint | 3.0.1 | 4.1.1 |
| langgraph-prebuilt | 1.0.5 | 1.1.0 |
| langgraph-sdk | 0.2.14 | 0.4.2 |

## Test plan
- [x] `uv sync --frozen`
- [x] `uv run python manage.py test` — 248 OK (6 skipped)
- [x] Import `consumers_graph` CompiledStateGraph OK
- [x] Confirm `Reviver.__init__` accepts `allowed_objects`
- [ ] Manual smoke: WebSocket chat + graph path (`consumers_graph`)

## References
- Issue: #10
- Prior pin: #9Reviewed-on: #14
2026-07-26 05:11:39 -07:00
westfarn 383c571137 update requirements (#9)
Unit Tests / test (push) Successful in 13s
Reviewed-on: #9
2026-07-25 19:06:16 -07:00
westfarn d1660792ad Dockerize chat_backend + Ollama LAN + DB file storage (#6) (#7)
Unit Tests / test (push) Successful in 13s
## Summary

Implements [chat_backend#6](#6) Part A:

- **uv** packaging (`pyproject.toml` + `uv.lock`), Docker/compose (dev + prod), entrypoint/validate-env, Gitea unit-test + auto-deploy workflows (mirror `scha`)
- Env-driven Django settings (`DJANGO_*`, `DATABASE_URL`, CSRF/CORS)
- **`OLLAMA_BASE_URL`** wired through all Ollama/LangChain clients (prod → `http://10.0.0.128:11434`)
- **DatabaseStorage** — prompt/document file blobs in Postgres (`StoredFile`), not container FS; RAG materializes temp paths for loaders
- ASGI via `gunicorn` + `UvicornWorker` (HTTP + WebSockets)

Companion server-infra PR registers `app_catalog` / `host_apps` (port **8003**).

## Test plan

- [ ] `uv sync && cd llm_be && SKIP_RAG_INIT=1 uv run python manage.py test`
- [ ] `docker compose build && docker compose up` against bundled Postgres
- [ ] Confirm Ollama calls use `OLLAMA_BASE_URL` (not hardcoded localhost)
- [ ] Upload a document / prompt file → row in `chat_backend_storedfile`, no disk under `media/`
- [ ] After server-infra merge + secret/Postgres/NPM: deploy via `deploy.sh --app chat_backend --env prod`Reviewed-on: #7
2026-07-25 05:23:33 -07:00