docs: add missing content from summary.md (API reference, Android app, file structure, LLM internals)
- docs/api-reference.md: complete REST API endpoint reference (~60+ routes) - docs/android-app.md: Flutter companion app stack, architecture, feature status - docs/architecture.md: detailed file-by-file reference for all backend services and frontend components - docs/features.md: LLM pipeline internals (intent routing, tool loop, duplicate guards, image search, research pipeline), roadmap - docs/development.md: full migration chain (0001–0026) with naming and caveats - README.md: link to new api-reference and android-app docs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -117,6 +117,65 @@ Settings are tabbed:
|
||||
| Logs (admin) | Error, audit, and usage logs with search |
|
||||
| Groups (admin) | Create/manage groups and membership |
|
||||
|
||||
## LLM Chat — Internal Pipeline
|
||||
|
||||
### Intent Routing
|
||||
|
||||
Before the main model runs, a lightweight intent classifier (`services/intent.py`) runs concurrently with `build_context()`. It makes a fast non-streaming call (~400ms) using a smaller dedicated model (`OLLAMA_INTENT_MODEL`, default `qwen2.5:7b`) to determine if the message requires a tool call.
|
||||
|
||||
**Skip heuristic** — Intent classification is skipped entirely for short messages (≤10 words) with no action/object keywords, saving 400–800ms on conversational replies.
|
||||
|
||||
**Prior-work fast-path** — Phrases like "research you did", "note you made", "using your research" skip the LLM call entirely and route to null (chat), preventing `search_web` from firing when the user references existing notes.
|
||||
|
||||
If a tool is detected, the intent's one-sentence `ack` field is streamed as the first chunk (becoming time-to-first-token), then the tool executes, then the main model generates a follow-up response with the tool result.
|
||||
|
||||
### Tool Loop
|
||||
|
||||
Multi-round tool loop (max 5 rounds). All tool implementations are in `services/tools.py` with `execute_tool()` as the dispatcher.
|
||||
|
||||
**Duplicate protection on create_note / create_task:**
|
||||
1. Exact title match (case-insensitive) → hard block, redirect to `update_note`
|
||||
2. Fuzzy title match (SequenceMatcher ≥ 82%; punctuation stripped before candidate search) → hard block
|
||||
3. Semantic content similarity (`semantic_search_notes` threshold 0.90, body ≥ 200 chars) → soft block with `requires_confirmation: true`
|
||||
|
||||
**Project resolution** (`_resolve_project`): 4-step lookup — (1) exact DB match, (2) `query in title` substring, (3) `title in query` reverse substring, (4) SequenceMatcher ≥ 0.55.
|
||||
|
||||
### Model Status
|
||||
|
||||
Three states returned by `GET /api/chat/status`:
|
||||
- `not_found` — model not installed; orange indicator in header
|
||||
- `cold` — installed but not loaded in VRAM; yellow pulsing indicator (first request will be slow)
|
||||
- `loaded` — hot in VRAM; green indicator
|
||||
|
||||
After `warmModel()` is called, a 5s polling loop runs for up to 60s until the indicator turns green.
|
||||
|
||||
### Context Window
|
||||
|
||||
`OLLAMA_NUM_CTX` (default 16384) controls the context window for all generation calls. Intent classification always uses `num_ctx=4096` to reduce VRAM pressure. History summarisation kicks in at 30 messages, keeps 8 recent, summary max 400 tokens.
|
||||
|
||||
### Image Search
|
||||
|
||||
`search_images` tool (SearXNG `categories=images`) fetches images server-side, stores on disk (SHA-256 dedup, 5 MB cap), and serves from `/api/images/<id>` — the user's browser never contacts the original image host. Requires `SEARXNG_URL`.
|
||||
|
||||
### Web Research Pipeline
|
||||
|
||||
Triggered by "research X and make a note" or the Research button in ChatView:
|
||||
1. Intent model generates 5 focused sub-queries as a JSON array
|
||||
2. All 5 SearXNG queries run in parallel (200ms stagger)
|
||||
3. Up to 15 unique URLs fetched in parallel
|
||||
4. Up to 12 sources passed to synthesis LLM (`num_ctx=16384`, `num_predict=8192`)
|
||||
5. Note created with `tags=["research"]`
|
||||
|
||||
SearXNG tip: add the app server IP to `botdetection.ip_lists.pass_ip` in SearXNG `settings.yml` to bypass the rate limiter for backend requests.
|
||||
|
||||
## Roadmap
|
||||
|
||||
- Calendar/timeline view for tasks with due dates
|
||||
- Email integration (read/send via IMAP/SMTP tools in chat)
|
||||
- Session invalidation on user deletion
|
||||
- Flutter push notifications (requires FCM/APNs — separate from web VAPID)
|
||||
- Flutter milestone support in project view
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
| Key | Action |
|
||||
|
||||
Reference in New Issue
Block a user