feat(rag): overlapping chunker, retrieval knobs, sqlite-vec index

- Chunker: char overlap across boundaries + hard-split of oversized paragraphs.
- Retrieval knobs: rag_top_k / rag_min_score in settings + Settings UI.
- Vector index: sqlite-vec ANN over document embeddings, dual-written and
  backfilled, with brute-force cosine as the guaranteed fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jon
2026-07-23 13:58:05 -05:00
co-authored by Claude Opus 4.8
parent ac0eb1e5f6
commit f4aea78b55
6 changed files with 216 additions and 11 deletions
+5 -1
View File
@@ -286,7 +286,11 @@ async def chat_stream_endpoint(payload: Dict[str, Any]):
system_prompt = (system_prompt + separator + memory_block) if system_prompt else memory_block
# Retrieve relevant uploaded documents (RAG) and inject the top chunks.
doc_hits = await store.search_documents(message, get_ollama_manager().embed, limit=3)
doc_hits = await store.search_documents(
message, get_ollama_manager().embed,
limit=app_settings.get("rag_top_k", 3),
min_score=app_settings.get("rag_min_score", 0.6),
)
doc_titles: list = []
if doc_hits:
doc_block = "\n\n".join(f"[{d['title']}]\n{d['text']}" for d in doc_hits)