feat(paperless): add memory persistence — Ollama embed + Qdrant + Postgres

- Parallel branch from Paperless Patch Metadati
- nomic-embed-text (768 dim) via Ollama for OCR text embedding
- Qdrant knowledge collection upsert with full doc metadata payload
- memory_facts upsert with source=paperless, dedup by paperless-{doc_id}
- Qdrant collections recreated at 768 dim (were 1536 legacy, 0 points)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-03-21 18:37:52 +00:00
parent aa4a2e8ae7
commit a145c0126c

View File

@@ -4,6 +4,32 @@ Tutte le modifiche significative al progetto ALPHA_PROJECT sono documentate qui.
---
## [2026-03-21] Paperless Upload — integrazione memoria Postgres + Qdrant
### Modifiche al workflow `📄 Paperless — Upload Documento [Multi]` (`GBPFFq8rmbdFrNn9`)
Aggiunto branch parallelo di salvataggio in memoria dopo `Paperless - Patch Metadati`:
```
Paperless - Patch Metadati ──┬──> Telegram - Conferma Upload (invariato)
└──> 🧠 Salva in Memoria ──> 💾 Upsert Memoria
```
**`🧠 Salva in Memoria` (Code):**
- Genera embedding del testo (`{title}\n\n{OCR excerpt}`) via Ollama `nomic-embed-text` (768 dim)
- Upsert in Qdrant collection `knowledge` con payload: `user_id`, `source`, `doc_id`, `title`, `category`, `doc_type`, `correspondent`, `created_date`, `tags`
- Prepara record per Postgres con `source_ref=paperless-{doc_id}`, TTL variabile per tipo doc (90gg ricevute, 180gg bollette, 365gg default, 730gg cedolini)
**`💾 Upsert Memoria` (Postgres → `mRqzxhSboGscolqI`):**
- `INSERT INTO memory_facts` con `source='paperless'`, dedup `ON CONFLICT memory_facts_dedup_idx DO UPDATE`
- Salva anche `qdrant_id` (UUID del punto Qdrant) per cross-reference futuro
### Qdrant collections riconfigurate
Ricreate `knowledge` e `episodes` con `size=768` (nomic-embed-text) — erano a 1536 (OpenAI legacy, 0 points).
---
## [2026-03-21] Jellyfin Playback Agent — Blocco A completato
### Nuovo workflow n8n