danny-avila/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 (RAG), specifically designed for use cases where embeddings are organized by file IDs. This allows for targeted queries based on file-level metadata, making it easier to integrate with platforms like LibreChat.
How it works
The API is built using FastAPI and Langchain, utilizing PostgreSQL with the pgvector extension (or Atlas MongoDB) as the vector store. It processes documents into chunks, generates embeddings using a variety of supported providers (such as OpenAI, Bedrock, VertexAI, or Ollama), and stores them with associated metadata. To ensure security, it implements a strict ownership scope where users can only read or delete content they own, verified via JWT tokens.
Who it’s for
Developers building RAG applications that require file-level document management and multi-tenant security, or those looking for a dedicated RAG backend for LibreChat.
Highlights
- Multi-Provider Embedding Support: Compatible with OpenAI, Azure, Bedrock, VertexAI, Google GenAI, Ollama, and Hugging Face.
- ID-Based Retrieval: Organizes embeddings by
file_idfor precise, file-specific querying. - Secure Scoping: Prevents unauthorized access to documents by resolving the caller's owner set before ranking results.
- Asynchronous Processing: Supports async operations and batched embedding processing to optimize memory usage and performance in constrained environments.
Related
- Project
- Project
- Project
- Project
- Project