Files
anything-llm-rag/README.md
salvacybersec 0eb84bab78 Update README: bge-m3 embedding, Olla proxy, verification system docs
- Correct embedding model: bge-m3:latest (1024d) via Olla proxy
- Document 3-layer verification system (per-call, first-batch, triple-check)
- Add monitor.py usage section
- Add full recovery procedures including lancedb/vector-cache cleanup
- Document Olla load balancer retry behavior
- Add technical notes on batch size, rate limiting, log buffering

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 01:34:16 +03:00

152 lines
4.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AnythingLLM × Persona RAG Integration
29 persona workspace'i olan, 39,754 dosyalık (67 GB) kitap kütüphanesinden beslenen RAG sistemi. 88 mapped path, 0 unmapped içerik klasörü. Diskte duplicate yok — aynı klasör birden fazla persona'ya atanabiliyor, her workspace kendi vektör embedding'ini tutar.
## Mimari
- **AnythingLLM Desktop** — `http://localhost:3001`
- **LLM:** Ollama (qwen3:8b) via Olla load balancer
- **Embedding:** Ollama — `bge-m3:latest` (1024d) via Olla
- **Vector DB:** LanceDB
- **Olla Proxy:** `http://100.85.70.44:40114/olla/ollama`
- **OCR:** ocrmypdf (tur+eng)
- **Kitap Kaynağı:** `/mnt/storage/Common/Books/` (39,754 dosya, 67 GB)
## Personalar (5 Cluster)
| Cluster | Personalar |
|---------|-----------|
| Intel | Frodo, Echo, Ghost, Oracle, Wraith, Scribe, Polyglot |
| Cyber | Neo, Bastion, Sentinel, Specter, Phantom, Cipher, Vortex |
| Military | Marshal, Centurion, Corsair, Warden, Medic |
| Humanities | Chronos, Tribune, Arbiter, Ledger, Sage, Herald, Scholar, Gambit |
| Engineering | Forge, Architect |
## Kullanım
### Durum Kontrolü
```bash
python3 setup.py --status
```
### Monitor (CLI + Web)
```bash
python3 monitor.py # tek seferlik CLI
python3 monitor.py --watch # canlı terminal (2s refresh)
python3 monitor.py --web # web dashboard http://localhost:8899
python3 monitor.py --web 9000 # custom port
```
### Workspace Oluştur / Güncelle
```bash
python3 setup.py --create-workspaces
python3 setup.py --create-workspaces --persona frodo
```
### Tam Pipeline (upload + OCR + embed)
```bash
python3 setup.py --upload-documents --resume
python3 setup.py --upload-documents --cluster cyber --resume
python3 setup.py --upload-documents --persona neo --priority 1 --resume
python3 setup.py --upload-documents --dry-run
```
### Re-assign (vektör recovery — tarama/upload yapmadan)
Dokümanlar zaten upload edilmiş ama vektörler silinmişse veya workspace atamaları bozulmuşsa:
```bash
python3 setup.py --reassign --reset # tüm workspace'ler
python3 setup.py --reassign --reset --cluster intel
python3 setup.py --reassign --reset --persona frodo
python3 setup.py --reassign --reset --dry-run # önizleme
python3 setup.py --reassign # sadece eksikleri tamamla
```
| Flag | Açıklama |
|------|----------|
| `--reassign` | Disk taraması yapmadan mevcut dosyaları embed eder |
| `--reset` | Önce workspace_docs kaydını sıfırlar |
| `--verbose` / `-v` | Debug-level console + log çıktısı |
## Embedding Doğrulama Sistemi
Script her embed işlemini 3 katmanlı doğrulamayla kontrol eder:
### Her API Çağrısı
- **5 retry** progressive backoff ile (Olla farklı instance'lara yönlendirebilir)
- API 200 dönse bile response body'de error kontrolü
- Art arda 5 fail → persona atlanır
### İlk Batch Doğrulama
- LanceDB dosyası fiziksel olarak büyüdü mü?
- Workspace'e test sorgusu — vektörler aranabilir mi?
- Model hatası → tüm işlem ABORT
### Persona Sonu — Triple Check
- **LanceDB fiziksel:** `.lance` dizin boyutu ve dosya sayısı
- **Workspace API:** Doküman sayısı kontrolü
- **Search testi:** Gerçek vektörel arama çalışıyor mu
### Pre-flight
- Embedding modeli Olla üzerinden 3 kez test edilir (ilk yükleme 120s sürebilir)
- Model bulunamazsa hiç başlamaz
## Pipeline
```
Phase A: Text dosyaları upload
Phase B: Scanned PDF'leri OCR (ocrmypdf)
Phase C: OCR'lı dosyaları upload
Final: Workspace'lere assign/embed (+ doğrulama)
```
`--reassign` modu sadece "Final" adımını çalıştırır.
## Recovery
### Vektör DB Silinirse
```bash
python3 setup.py --reassign --reset
```
### Tek Persona Recovery
```bash
python3 setup.py --reassign --reset --persona frodo
```
### Tam Sıfırlama
```bash
rm upload_progress.json
rm -rf ~/.config/anythingllm-desktop/storage/lancedb/*.lance
rm -rf ~/.config/anythingllm-desktop/storage/vector-cache/*
python3 setup.py --all
```
## Dosyalar
| Dosya | Açıklama |
|-------|----------|
| `setup.py` | Ana entegrasyon scripti (upload, OCR, embed, reassign, verification) |
| `config.yaml` | Persona-klasör eşlemeleri (29 persona, 88 path), batch ayarları |
| `monitor.py` | CLI + web dashboard (progress, log tail, cluster view) |
| `setup.log` | Detaylı log dosyası (gitignore'd) |
| `upload_progress.json` | Upload/atama state tracker (gitignore'd) |
| `ocr_output/` | OCR çıktıları (gitignore'd) |
## Teknik Notlar
- Olla load balancer birden fazla Ollama instance'a dağıtır — embedding modeli her instance'da olmayabilir, bu yüzden her istek 5 retry yapılır
- Batch boyutu 5 doc — daha büyük batch'lerde AnythingLLM hang edebilir
- Batch arası 5 saniye bekleme (rate limit koruması)
- `direct-uploads/``/mnt/storage/anythingllm/direct-uploads/` (HDD symlink, SSD tasarrufu)
- `--resume` flag'i kesilen işlemi kaldığı yerden devam ettirir
- Log dosyası line-buffered — arka planda çalışırken bile anlık yazılır