feat(rag): add multi-tenant hybrid search, LLM streaming, token metering, conversation memory & full-stack UI - #2478
Closed
VimalN2005 wants to merge 7 commits into
Closed
feat(rag): add multi-tenant hybrid search, LLM streaming, token metering, conversation memory & full-stack UI#2478VimalN2005 wants to merge 7 commits into
VimalN2005 wants to merge 7 commits into
Conversation
… knowledge base + AI chat streaming UI
Contributor
|
This PR modifies dependency files ( If you need a dependency change, please open a discussion describing what you need and why. Closing this PR automatically. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR introduces a comprehensive, production-grade Retrieval-Augmented Generation (RAG) & Conversational AI capability to the full-stack template, maintaining multi-tenant isolation, enterprise token governance, and modern UI integration.
Key Capabilities Added
Multi-Tenant Hybrid Search (
pgvector+ Full-Text Search)pgvector/pgvector:pg17incompose.yml.DocumentandDocumentChunkmodels withVector(1536)embeddings andowner_idindexing for strict tenant isolation.tsvector) using Reciprocal Rank Fusion (RRF).Two-Stage Hybrid Retrieval & Cross-Encoder Re-Ranking
rerank-v3.5).Abort-Aware LLM Token Streaming (SSE)
sources,token,done).await request.is_disconnected(). If a user closes their tab or cancels generation, upstream LLM connections and compute are aborted immediately to prevent token leakage.AI Token Metering & Budget Quota Guardrails
HTTP 429 Too Many Requestswhen limits are exceeded (Superusers are exempt).Multi-Turn Conversation Memory & Chat Sessions
ChatSessionandChatMessagemodels with JSON source chunk metadata.Async Document Ingestion via Background Tasks
POST /api/v1/rag/documents?background=truereturns202 Acceptedand offloads chunking/embedding to FastAPIBackgroundTasks.status(processing|ready|failed) and status polling endpointGET /api/v1/rag/documents/{id}/status.Full-Stack Frontend UI (React 19 + TanStack Router & Query + Tailwind CSS)
/documents):/chat):AbortController.Verification & Testing
uv run pytest tests) covering hybrid search, reranking, SSE streaming, multi-turn memory, token metering quotas, and async ingestion.bun run buildandbun run lintpass with 0 errors (TypeScript compilation succeeded in 864ms).