Add rag module: Spring AI 2.0 RAG with pgvector, chunking, reranking and a faithfulness check

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
This commit is contained in:
Claude
2026-09-21 19:09:05 +00:00
commit 1d4625a1c2
62 changed files with 3715 additions and 0 deletions
@@ -0,0 +1,14 @@
# Ingesting the same handbook more than once (real PostgreSQL + pgvector)
rows are counted with: select count(*) from vector_store
1. first upload -> status=ingested chunksWritten=4 chunksReplaced=0 | rows in table=4, texts embedded so far=4
2. same bytes again -> status=skipped chunksWritten=0 chunksReplaced=0 | rows in table=4, texts embedded so far=4
3. page 2 edited (20 -> 22 days) -> status=updated chunksWritten=4 chunksReplaced=4 | rows in table=4, texts embedded so far=8
rows still saying "20 working days": 0, rows saying "22 working days": 1
4. same text, exported again -> status=updated chunksWritten=4 chunksReplaced=4 | rows in table=4, texts embedded so far=12
the two PDFs have identical text and different bytes: true
the file hash is a hash of bytes, so a re-export counts as a change and is re-embedded
--- the naive version: vectorStore.add() on every upload, nothing remembered ---
the same 4 chunks added on two more uploads: rows in table 4 -> 12
rows saying "22 working days" now: 3