Add Matrix NL-query Q&A surface (W2 step 5)
Read-only natural-language query over the curated nl_query endpoint, answered in-thread. Two entry points (room-per-purpose model): a dedicated Q&A room (MATRIX_QUERY_ROOM) where every top-level message is a question, plus the ?/@bot trigger in the intake room as a cross-room convenience. Both routes hit the same handle_query -> crm_client.nl_query -> POST /api/query/nl; translation runs on the box's local model, nothing leaves the box, and there is no write path so no approval gate applies. Pure logic (trigger parsing, answer rendering) in query.py with offline tests; async room wiring in bot.py (live-smoke only, per the bot's convention). Bot-side only, ships on the Spark via git pull + restart. Depends on the box-side /api/query/nl endpoint, which lands with the v93 s9pk (reminders + W2): until v93 is installed the Q&A surface 404s, so the bot deploy is staged to follow that install.
This commit is contained in:
@@ -54,6 +54,13 @@ Keep the two in sync; the soft-delete test guards the copy.
|
||||
- `POST /api/query/nl` (`require_bot_or_admin`, read-only) — body `{question}` (local translate)
|
||||
or `{intent, slots}` (direct, e.g. a UI re-run). Returns `{intent, slots, rows, summary,
|
||||
question}`. `GET /api/query/catalog` returns the askable surface for the UI.
|
||||
- **Clients (thin):** the **Matrix Q&A** surface is built — it lives bot-side in
|
||||
`backend/matrix_intake/query.py` (trigger grammar + deterministic answer rendering) +
|
||||
`crm_client.nl_query`, and ships on the Spark (no s9pk for the bot). Two entry points: a
|
||||
**dedicated Q&A room** (`MATRIX_QUERY_ROOM`, every message is a question) and the `?`/`@bot`
|
||||
trigger in the intake room. **It depends on this endpoint being live on the box** — which lands
|
||||
with the v93 s9pk (reminders + W2); deploy the bot only after that, or it 404s. See the
|
||||
matrix-intake guide. The **web "Ask" box** (Communications tab) is the remaining client.
|
||||
- Status: local-model outage → **503**; unexpected SQL fault → **500**; everything else
|
||||
(a hit, or a soft `no_match`/`unknown_intent`) → **200** with the structured result, because
|
||||
the UI always wants the interpreted query back, not a bare code.
|
||||
|
||||
Reference in New Issue
Block a user