Dushnilin
|
421a4fd796
|
feat: add RAG (Retrieval-Augmented Generation) for AI Doctor
New files:
- tools/rag_build_index.sh: build-time ingestion pipeline
Chunks docs/knowledge-base/*.md into 2000-char chunks with 200-char overlap
Produces rag_index.json (39 chunks, ~74KB) for runtime embedding
- tachyon/files/usr/lib/diagnostics/rag.uc: runtime RAG module
Embeds chunks via same LLM provider API (OpenAI-compatible /v1/embeddings)
Cosine similarity search, top-3 retrieval, 24h cache in /tmp
Graceful fallback if embedding API unavailable
- tachyon/files/usr/lib/tachyon/rag_index.json: pre-built chunk index
Modified files:
- runtime.uc: integrated RAG into ai_doctor() function
Retrieves relevant docs based on user query or diagnostic context
Injects 'Relevant Documentation' section into LLM prompt
- renderAdvancedSettings.ts: added 'Enable RAG' toggle in AI Doctor settings
- tachyon config: added enable_rag option (default '1')
- build.sh: added rag_build_index.sh step
Architecture:
- Provider-agnostic: uses same API key/provider as LLM for embeddings
- Embedding model: text-embedding-3-small (OpenAI), nomic-embed-text (Ollama),
local-model (LMStudio), deepseek-embedding (DeepSeek)
- Cache: embeddings cached in /tmp/tachyon_rag_embeddings.json (24h TTL)
- Fallback: if embedding fails, AI Doctor works without RAG (as before)
- 39 chunks from 14 docs, ~66K chars, cosine search <1ms
623 tests pass (101 backend + 522 frontend)
|
2026-08-20 10:27:56 +03:00 |
|