Package: r2r
R2R: Production-ready RAG systems.A semi-opinionated RAG framework.R2R was conceived to bridge the gap between experimental RAG models and robust, production-ready systems. Our semi-opinionated framework cuts through the complexity, offering a straightforward path to deploy, adapt, and maintain RAG pipelines in production. We prioritize simplicity and practicality, aiming to set a new industry benchmark for ease of use and effectiveness.Quick Install:Install R2R directly usingpip:# use the `'r2r[all]'` to download all required depspipinstall'r2r[parsing,eval]'# setup envexportOPENAI_API_KEY=sk-...exportLOCAL_DB_PATH=local.sqlite# OR do `vim .env.example && cp .env.example .env`LinksJoin the Discord serverRead our DocsBasic ExamplesThe project includes several basic examples that demonstrate application deployment and interaction:app.py: This example runs the main application, which includes the ingestion, embedding, and RAG pipelines served via FastAPI.uvicornr2r.examples.basic.app:appbasic client: This example should be run after starting the main application. It demonstrates uploading text entries as well as a PDF to the local server with the python client. Further, it shows document and user-level vector management with built-in features.python-mr2r.examples.basic.run_clientpdf chat: An example demonstrating upload and chat with a more realistic pdf.# Ingest pdfpython-mr2r.examples.pdf_chat.run_clientingest# Ask a questionpython-mr2r.examples.pdf_chat.run_clientsearch"What are the key themes of Meditations?"academy: A more sophisticated demo demonstrating how to build a more novel pipeline which involves synthetic queries# launch academy applicationuvicornr2r.examples.academy.app:app# Ask a questionpython-mr2r.examples.academy.run_clientsearch"What are the key themes of Meditations?"web: A web application which is meant to accompany the framework to provide visual intelligence.cd$workdir/web&&pnpminstall# Serve the web apppnpmdevDemoFull Install:Follow these steps to ensure a smooth setup:Install Poetry:Before installing the project, make sure you have Poetry on your system. If not, visit theofficial Poetry websitefor installation instructions.Clone and Install Dependencies:Clone the project repository and navigate to the project directory:gitclonegit@github.com:SciPhi-AI/r2r.gitcdr2rCopy the.env.examplefile to.env. This file is in the main project folder:cp.env.example.env# Add secrets, `OPENAI_API_KEY` at a minimumvim.envInstall the project dependencies with Poetry:# See pyproject.toml for available extras# use "all" to include every optional dependencypoetryinstall-Eparsing-EevalExecute with poetry run:python-mr2r.examples.pdf_chat.run_clientingestConfigure Environment Variables:You need to set up cloud provider secrets in your.env. At a minimum, you will need an OpenAI key.The framework currently supports PostgreSQL (locally), pgvector and Qdrant with plans to extend coverage.Key Features🚀 Rapid Deployment: Facilitates a smooth setup and development of production-ready RAG systems.⚖️ Flexible Standardization:Ingestion,Embedding, andRAGwith properObservability.🧩 Easy to modify: Provides a structure that can be extended to deploy your own custom pipelines.📦 Versioning: Ensures your work remains reproducible and traceable through version control.🔌 Extensibility: Enables a quick and robust integration with various VectorDBs, LLMs and Embeddings Models.🤖 OSS Driven: Built for and by the OSS community, to help startups and enterprises to quickly build with RAG.📝 Deployment Support: Available to help you build and deploy your RAG systems end-to-end.Core AbstractionsThe framework primarily revolves around three core abstractions:TheIngestion Pipeline: Facilitates the preparation of embeddable 'Documents' from various data formats (json, txt, pdf, html, etc.). The abstraction can be found iningestion.py.TheEmbedding Pipeline: Manages the transformation of text into stored vector embeddings, interacting with embedding and vector database providers through a series of steps (e.g., extract_text, transform_text, chunk_text, embed_chunks, etc.). The abstraction can be found inembedding.py.TheRAG Pipeline: Works similarly to the embedding pipeline but incorporates an LLM provider to produce text completions. The abstraction can be found inrag.py.TheEval Pipeline: Samples some subset of rag_completion calls for evaluation. CurrentlyDeepEvalis supported. The abstraction can be found ineval.py.Each pipeline incorporates a logging database for operation tracking and observability.