LOT 1 - Optimizare script build -Instalare mono comanda
This commit is contained in:
parent
5380c3fc63
commit
42ff22bf85
127 changed files with 16163 additions and 532 deletions
|
|
@ -1,6 +1,13 @@
|
|||
# DidiBrain — Status Snapshot
|
||||
|
||||
**Last updated:** 2026-04-23 (integration session — web-api cache + backend verification cache)
|
||||
|
||||
> **Note (current):** the platform is **LIVE and functional**. Since this
|
||||
> snapshot the stack grew to **four containers** (added `didibrain-scheduler`),
|
||||
> the analysis-atom cache (v2, gold/silver/bronze) and the Cache Freshness
|
||||
> Defense layer (feeder + auditor + watcher) shipped, and the live working
|
||||
> model is **`qwen3.5`** (vLLM, `MODEL_FAST` enabled). Sections below that
|
||||
> still say "3 containers / 5 endpoints / 397B" are corrected inline.
|
||||
**Working dir:** `/home/admin365/ml-projects/modules/didi_brain/`
|
||||
**Related docs:**
|
||||
- `CONTRACT_VERIFICATION_CACHE.md` — contract backend↔brain pentru verification cache (v2, current)
|
||||
|
|
@ -17,24 +24,31 @@ DidiBrain is **SHIP READY** și **INTEGRATED**. Pe lângă contractul inițial H
|
|||
- **Verification cache pentru didi-backend** — post-LLM stance/verdict storage
|
||||
cu 4 staleness states (fresh / stale_framework / stale_prompt / miss)
|
||||
|
||||
**Trei containere, zero regressions pe funcționalitatea v1.** Tabelul relational
|
||||
nou `brain_verification_cache` trăiește în același Postgres cu atomic-server,
|
||||
prefix `brain_` pentru izolare.
|
||||
- **Analysis atom cache (v2)** — techniques + ai_tampered + claims full-component
|
||||
results, 3-tier gold/silver/bronze (since 2026-05-01)
|
||||
- **Cache Freshness Defense** — `didibrain-scheduler` (feeder + auditor + watcher)
|
||||
keeps cached verdicts fresh
|
||||
|
||||
**Patru containere, zero regressions pe funcționalitatea v1.** Tabelele relationale
|
||||
noi `brain_verification_cache` + `brain_analysis_atom` (și layerul fact_status)
|
||||
trăiesc în același Postgres cu atomic-server, prefix `brain_` pentru izolare.
|
||||
|
||||
## Current state in 30 seconds
|
||||
|
||||
```
|
||||
3 containers running continuously, all healthy
|
||||
4 containers running continuously, all healthy
|
||||
|
||||
didibrain-api brain_api FastAPI service :8090 52 MB RAM
|
||||
didibrain-atomic atomic-server (API only) :8088 83 MB RAM
|
||||
didibrain-postgres pgvector pg16 :5434 60 MB RAM
|
||||
(+ brain_verification_cache table)
|
||||
didibrain-api brain_api FastAPI service :8090 52 MB RAM
|
||||
didibrain-atomic atomic-server (API only) :8088 (8080 internal) 83 MB RAM
|
||||
didibrain-postgres pgvector pg16 :5434 60 MB RAM
|
||||
(+ brain_verification_cache
|
||||
+ brain_analysis_atom tables)
|
||||
didibrain-scheduler feeder + auditor + watcher (no port)
|
||||
|
||||
Brain contents (grow continuously via web-api ingest + manual bootstrap)
|
||||
79 tags (canonical taxonomy, 7 root namespaces)
|
||||
19+ documents (initial Wikipedia vaccines seed + anything premium adds)
|
||||
509+ claims (extracted by Qwen 397B, substring validated)
|
||||
509+ claims (extracted by qwen3.5, substring validated)
|
||||
|
||||
Verification cache (new in v2 — Apr 23)
|
||||
brain_verification_cache UNIQUE (claim_hash, tier)
|
||||
|
|
@ -82,7 +96,7 @@ Didi backend ┌─────────────
|
|||
│ DidiBrain stack │
|
||||
│ │
|
||||
│ ┌──────────────────────┐ │
|
||||
│ │ brain-api :8090 │ FastAPI + Uvicorn, 5 v1 endpoints │
|
||||
│ │ brain-api :8090 │ FastAPI + Uvicorn, full route set │
|
||||
│ │ (didibrain-api) │ speaks Didi contract 1:1 │
|
||||
│ └──────────┬───────────┘ │
|
||||
│ │ HTTP (docker DNS) │
|
||||
|
|
@ -97,25 +111,26 @@ Didi backend ┌─────────────
|
|||
│ │ HTTPS
|
||||
│ ▼
|
||||
│ ┌────────────────────────────────┐
|
||||
│ │ BGE-M3 embeddings │ 10.11.10.15:8200
|
||||
│ │ BGE-M3 embeddings │ 10.11.10.15:14100
|
||||
│ │ (vLLM OpenAI-compat) │ 1024 dim, 8K ctx, multilingual
|
||||
│ └────────────────────────────────┘
|
||||
│
|
||||
│ ┌────────────────────────────────┐
|
||||
│ │ BGE-reranker-v2-m3 │ 10.11.10.15:8100
|
||||
│ │ BGE-reranker-v2-m3 │ 10.11.10.15:14200
|
||||
│ │ (cross-encoder) │ precision boost
|
||||
│ └────────────────────────────────┘
|
||||
│
|
||||
│ ┌────────────────────────────────┐
|
||||
└─▶│ Qwen3.5-397B-A17B │ 10.11.10.17:14011 (router)
|
||||
└─▶│ qwen3.5 │ 10.11.10.17:14011 (router)
|
||||
│ via LLM router │ round-robin to .18 and .19
|
||||
│ (llama.cpp + vLLM backends) │ claim extraction, NLI
|
||||
│ (vLLM backends) │ claim extraction, NLI
|
||||
└────────────────────────────────┘
|
||||
```
|
||||
|
||||
All upstream endpoints live on a VPN-routed 10.11.10.x network. The Docker
|
||||
containers reach them through WSL2 NAT (Docker Desktop) or host networking
|
||||
(Linux server).
|
||||
All upstream endpoints (LLM router, BGE-M3, reranker) are reached over Docker
|
||||
DNS on the shared external `didi-network` as `didiAI-llm-api:14011`,
|
||||
`didiAI-embeddings-api:14100`, and `didiAI-rerank-api:14200` (the 10.11.10.x
|
||||
addresses above are the host-side equivalents).
|
||||
|
||||
## Repo layout
|
||||
|
||||
|
|
@ -131,7 +146,7 @@ didibrain/
|
|||
├── AUDIT.md # initial upstream Atomic audit
|
||||
│
|
||||
├── infra/
|
||||
│ └── docker-compose.yml # 3-service stack (+ optional atomic-web)
|
||||
│ └── docker-compose.yml # 4-service stack (api, atomic, postgres, scheduler)
|
||||
│
|
||||
├── brain_api/ # HTTP service — the main deliverable
|
||||
│ ├── Dockerfile
|
||||
|
|
@ -184,7 +199,7 @@ didibrain/
|
|||
├── 06_validate_queries.py # smoke test doc-level retrieval
|
||||
├── 07_run_extraction.py # claim extraction batch
|
||||
├── 08_validate_claims.py # smoke test claim-level retrieval
|
||||
├── 09_brain_api_demo.py # brain_api contract test (all 5 endpoints)
|
||||
├── 09_brain_api_demo.py # brain_api contract test (core web-gathering endpoints)
|
||||
├── 10_run_lint.py # Lint pass runner (--limit --force)
|
||||
├── 11_show_contradictions.py # read state file, render top contradictions
|
||||
└── bootstrap_deploy.sh # fresh-server deploy orchestrator
|
||||
|
|
@ -209,6 +224,17 @@ backends.
|
|||
| `POST /v1/gather` with `run_nli:false` | claim → evidence | ~1.5-2 s | skip stance classification for speed |
|
||||
| `POST /v1/image-search` | stub | <5 ms | always empty list |
|
||||
| `POST /v1/ingest` | populate from web module | variable | creates atoms + optional async extraction |
|
||||
| `POST /v1/verification_cache` | write claim verification result | <50 ms | claims cache (v2) |
|
||||
| `POST /v1/analysis_atom/lookup` | read cached analysis | <50 ms | techniques / ai_tampered / claims |
|
||||
| `POST /v1/analysis_atom` | write analysis atom | <50 ms | silver/bronze by `llm_confidence` |
|
||||
| `PATCH /v1/analysis_atom/{id}` | promote to gold | <50 ms | moderator review |
|
||||
| `GET /v1/analysis_atom/stats` | per-tier/component counts | <20 ms | 24h hit rate |
|
||||
| `POST /v1/canonicalize` | temporal claim disambiguation | LLM-bound | Pilon 7 |
|
||||
| `POST /v1/cache/invalidate` | mass invalidation (`dry_run`) | variable | Pilon 8 |
|
||||
| `GET /v1/cache/audit_log` | audit browser | <50 ms | paginated |
|
||||
| `GET/PATCH /v1/fact_status/*` | versioned fact-status layer | <50 ms | list/detail/versions/override |
|
||||
|
||||
(Full set ~30 routes incl. FastAPI auto docs; see `INDEX.md` for the canonical list.)
|
||||
|
||||
### /v1/gather response shape (key fields)
|
||||
|
||||
|
|
@ -297,9 +323,9 @@ or in README.md under "Production deploy".
|
|||
Only the upstream endpoint URLs may need updating:
|
||||
|
||||
```bash
|
||||
LLM_ROUTER_URL=http://10.11.10.17:14011 # if router is on VPN, unchanged
|
||||
EMBEDDING_URL=http://10.11.10.15:8200 # if BGE is on VPN, unchanged
|
||||
RERANKER_URL=http://10.11.10.15:8100 # if reranker is on VPN, unchanged
|
||||
LLM_ROUTER_URL=http://10.11.10.17:14011 # didiAI-llm-api, unchanged
|
||||
EMBEDDING_URL=http://10.11.10.15:14100 # didiAI-embeddings-api, unchanged
|
||||
RERANKER_URL=http://10.11.10.15:14200 # didiAI-rerank-api, unchanged
|
||||
```
|
||||
|
||||
Everything else (`ATOMIC_URL`, ports, model names, Postgres creds) is either
|
||||
|
|
@ -344,15 +370,13 @@ curl -s -X POST http://localhost:8090/v1/gather \
|
|||
call this endpoint; we read `embedding_status` per atom via `list_atoms`
|
||||
or `get_atom` instead.
|
||||
|
||||
3. **Qwen 35B (vLLM on :14001)** — thinking mode stuck ON via the router and
|
||||
safety alignment refuses disinfo-extraction tasks. Disabled in config
|
||||
(`MODEL_FAST_ENABLED=false`); the whole pipeline runs on Qwen 397B. If a
|
||||
future session un-sticks 35B, Lint pass could speed up ~4x by using it.
|
||||
3. **Fast model `qwen3.5`** — now **enabled** (`MODEL_FAST_ENABLED=true`) and
|
||||
is the live working model for the whole pipeline (extraction, NLI, gather)
|
||||
via the LLM router at `didiAI-llm-api:14011` (vLLM). (Historically the fast
|
||||
model was disabled and the pipeline ran on a separate reasoning model; that
|
||||
is no longer the case.)
|
||||
|
||||
4. **Gemma 31B endpoint (10.11.10.16:8001)** — port unreachable (host pings
|
||||
OK). Not used by any feature; listed as optional in `.env`.
|
||||
|
||||
5. **Atomic's React UI not running** — we only deploy `atomic-server` (API),
|
||||
4. **Atomic's React UI not running** — we only deploy `atomic-server` (API),
|
||||
not `atomic-web` (React frontend). `http://localhost:8088/` returns 404
|
||||
for this reason. Brain_api has its own Swagger UI at `/docs` which covers
|
||||
dev-testing needs. If visual atom/tag/wiki browsing is needed, add an
|
||||
|
|
@ -362,7 +386,7 @@ curl -s -X POST http://localhost:8090/v1/gather \
|
|||
|
||||
| Symptom | Root cause | Fix |
|
||||
|---|---|---|
|
||||
| `/health` timeouts | BGE endpoint unreachable (VPN down?) | `curl http://10.11.10.15:8200/v1/models` on host; bring VPN back |
|
||||
| `/health` timeouts | BGE endpoint unreachable | `curl http://10.11.10.15:14100/v1/models` on host; restore upstream reachability |
|
||||
| `/v1/gather` returns 500 silently | Same as above — Atomic can't embed the query | Same fix |
|
||||
| Post-reboot: brain_api empty reply | uvicorn bound to 127.0.0.1 inside container (not 0.0.0.0) | Rebuild — Dockerfile now sets `BRAIN_API_HOST=0.0.0.0` |
|
||||
| `LLM_ROUTER_URL` points to localhost but nothing there | Router is actually on 10.11.10.17:14011 (not on the dev box) | Update `.env`; validated in session 2 |
|
||||
|
|
@ -396,12 +420,12 @@ curl -s -X POST http://localhost:8090/v1/gather \
|
|||
- Built `shared/` + `extractor/` + scripts 01-08
|
||||
- Stood up Atomic + Postgres in compose
|
||||
- Imported 19 Wikipedia vaccines articles, EN + RO
|
||||
- Extracted 513 claims via Qwen 397B (1.2% hallucination drop)
|
||||
- Extracted 513 claims via qwen3.5 (1.2% hallucination drop)
|
||||
- Validated claim-level retrieval (cross-lingual RO↔EN confirmed)
|
||||
|
||||
### Session 2 (2026-04-11, ~4 hours)
|
||||
- Re-onboarded state after VPN restart (fixed LLM router URL)
|
||||
- Built `brain_api/` FastAPI service with 5-endpoint Didi contract
|
||||
- Built `brain_api/` FastAPI service with the Didi web-gathering contract
|
||||
- Dockerized brain_api (self-sufficient startup, taxonomy refresh from atomic)
|
||||
- Added NLI stance-vs-query pass in `/v1/gather` (additive fields in `brain_meta`)
|
||||
- Fixed NLI concurrency (MAX_PARALLEL=2 matches llama.cpp backends)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue