SciPhi R2R
Project description
R2R: Production-ready RAG systems.
A semi-opinionated RAG framework.
Demo(s)
Launching the server locally, running the client, and pipeline observabiilty application:
Launching the basic chat client and running a test query:
https://github.com/SciPhi-AI/R2R/assets/68796651/dc44309f-a52c-4c2a-b0ab-80140e6a2fff
Quick Install:
Install R2R directly using pip:
# use the `'r2r[all]'` to download all required deps
pip install 'r2r[parsing,eval]'
# setup env
export OPENAI_API_KEY=sk-...
export LOCAL_DB_PATH=local.sqlite
# OR do `vim .env.example && cp .env.example .env`
# INCLUDE secrets and modify config.json
# if using cloud providers (e.g. pgvector, supabase, ...)
Run the server with Docker:
docker pull emrgntcmplxty/r2r:latest
# Place your secrets in `.env` before deploying
docker run -d --name r2r_container -p 8000:8000 --env-file .env r2r
Links
Basic Examples
The project includes several basic examples that demonstrate application deployment and interaction:
-
basic app: This example runs the backend server, which includes the ingestion, embedding, and RAG pipelines served via FastAPI.# If using a venv, replace `uvicorn` with `venv_path/bin/uvicorn` uvicorn r2r.examples.basic.app:app
-
basic client: This example should be run after starting the server. 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 -m r2r.examples.basic.run_client
-
pdf chat: An example demonstrating upload and chat with a more realistic pdf.# Ingest pdf python -m r2r.examples.pdf_chat.run_client ingest # Return search results python -m r2r.examples.pdf_chat.run_client search "What are the key themes of Meditations?" # Stream a rag response poetry run python -m r2r.examples.pdf_chat.run_client rag_completion_streaming "According to Meditaitons, what are some principles to live by?"
-
academy: A more sophisticated demo demonstrating how to build a more novel pipeline which involves synthetic queries# Launch the `academy` example application # If using a venv, replace `uvicorn` with `venv_path/bin/uvicorn` uvicorn r2r.examples.academy.app:app # Ask a question python -m r2r.examples.academy.run_client search "What are the key themes of Meditations?"
-
intelligence: A web application which communicates with the backend server to provide visual intelligence.cd $workdir/web && pnpm install # Serve the web app pnpm dev
-
chat: A chat application which communicates with the basic pipeline to stream chat responses and sources in real time.cd $workdir/chat && pnpm install # Serve the web app pnpm dev
Full 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 the official Poetry website for installation instructions.
-
Clone and Install Dependencies:
-
Clone the project repository and navigate to the project directory:
git clone git@github.com:SciPhi-AI/r2r.git cd r2r
-
Copy the
.env.examplefile to.env. This file is in the main project folder:cp .env.example .env # Add secrets, `OPENAI_API_KEY` at a minimum vim .env
-
Install the project dependencies with Poetry:
# See pyproject.toml for available extras # use "all" to include every optional dependency poetry install -E parsing -E eval
-
Execute with poetry run:
python -m r2r.examples.pdf_chat.run_client ingest
- Configure 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.
- You need to set up cloud provider secrets in your
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 Abstractions
The framework primarily revolves around three core abstractions:
-
The Ingestion Pipeline: Facilitates the preparation of embeddable 'Documents' from various data formats (json, txt, pdf, html, etc.). The abstraction can be found in
ingestion.py. -
The Embedding 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 in
embedding.py. -
The RAG Pipeline: Works similarly to the embedding pipeline but incorporates an LLM provider to produce text completions. The abstraction can be found in
rag.py. -
The Eval Pipeline: Samples some subset of rag_completion calls for evaluation. Currently DeepEval is supported. The abstraction can be found in
eval.py.
Each pipeline incorporates a logging database for operation tracking and observability.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file r2r-0.1.25.tar.gz.
File metadata
- Download URL: r2r-0.1.25.tar.gz
- Upload date:
- Size: 3.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.5.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bed45e4b1f3512d890dd86104d7980a6091b4b0e1fce8727409ff3d956ad9165
|
|
| MD5 |
ecc4228dce3887c2d170ae90126c52b1
|
|
| BLAKE2b-256 |
839ac9f726f9581d2f9a61799db0f1fee244b48e86bbf644588112c1fc3ae55e
|
File details
Details for the file r2r-0.1.25-py3-none-any.whl.
File metadata
- Download URL: r2r-0.1.25-py3-none-any.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.5.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da68bec2a80be17c33882a3893754d34923a467441b787da81f6821b78527907
|
|
| MD5 |
f118da2e243be5e50d7c760a0f09ea74
|
|
| BLAKE2b-256 |
ce3e0e3377bf493a720bbe3d16b2ab5213b9e32ad95366c29e9f2b54a9563cfe
|