LibreChat-AI/rag-api
ID-based RAG FastAPI: Integration with Langchain and PostgreSQL/pgvector
What it solves
This project provides a scalable, asynchronous API for document indexing and retrieval, specifically designed for ID-based Retrieval-Augmented Generation (RAG). It allows users to organize embeddings by file_id, enabling targeted queries based on specific files or metadata, which is essential for applications like LibreChat.
How it works
Built with FastAPI and Langchain, the API manages the documents through a vector store (defaulting to PostgreSQL/pgvector or Atlas MongoDB). It converts documents into embeddings using various providers (OpenAI, Bedrock, Azure, Hugging Face, Google, etc.) and and processes them in asynchronous batches to maintain performance and low memory usage. A critical security layer ensures that users can only read or delete content they own, based on verified JWT tokens.
Who it’s for
Developers building AI applications that require a file-level RAG system where documents are associated with specific IDs and user ownership is strictly enforced.
Highlights
- Multi-Provider Embedding Support: Compatible with OpenAI, Azure, Bedrock, VertexAI, Ollama, and Hugging Face.
- ID-Based Retrieval: Organizes embeddings by
file_idfor precise, metadata-driven querying. - Ownership-Based Security: Implements strict scoping so users can only access chunks they own.
- Scalable Ingestion: Features asynchronous batch processing to handle large files in memory-constrained environments.
- Flexible Vector Storage: Supports both pgvector and Atlas MongoDB.
Related
- Project
- Project
- Project
- Project