* quiet logger (#482) * Add debug mode to Posthog (#480) * Feature/add kg agent search to pipeline rebased 2 (#483) * expand search pipeline * checkin progress * checkin progress * grinding out * make sure we can configure kg * fix id error on server use * checkin * finish merge, add rag stream * cleanup and pass tests * up * harmonize * check in config refactor * checkin work * cleanup * minor cleanups * Add optional metadata to KG cookbook (#484) * Add optional metadata to KG cookbook * Align CB with script * rm cruft and fix bug (#488) * Feature/refactor app logic (#490) * modularize app logic * add management service * add management service * add management service * Feature/move to singleton to prevent reload rebased (#491) * modularize app logic * add management service * prevent r2r reload * prevent r2r reload * add back file (#492) * add back file (#493) * add back file * fix bugs * fix the routes (#496) * rebase * update docs * cleanups --------- Co-authored-by: Nolan Tremelling <34580718+NolanTrem@users.noreply.github.com>
6.9 KiB
The ultimate open source AI powered answer engine
About
R2R (RAG to Riches) bridges local LLM experiments with production-ready Retrieval-Augmented Generation (RAG). It offers developers a cutting-edge, comprehensive RAG system with a RESTful API for seamless integration.
For a more complete view of R2R, check out the full documentation.
Key Features
- 📁 Multimodal Support: Ingest files ranging from
.txt,.pdf,.jsonto.png,.mp3, and more. - 🔍 Hybrid Search: Combine semantic and keyword search with reciprocal rank fusion for enhanced relevancy.
- 🔗 Graph RAG: Automatically extract relationships and build knowledge graphs.
- 🗂️ App Management: Efficiently manage documents and users with rich observability and analytics.
- 🌐 Client-Server: RESTful API support out of the box.
- 🧩 Configurable: Provision your application using intuitive configuration files.
- 🔌 Extensible: Develop your application further with easy builder + factory pattern.
- 🖥️ Dashboard: Use the R2R Dashboard, an open-source React+Next.js app for a user-friendly interaction with R2R.
Table of Contents
Install
Note
Windows users are advised to use Docker to run R2R.
Installing with Pip 🐍
pip install r2r
# setup env
export OPENAI_API_KEY=sk-...
export POSTGRES_USER=YOUR_POSTGRES_USER
export POSTGRES_PASSWORD=YOUR_POSTGRES_PASSWORD
export POSTGRES_HOST=YOUR_POSTGRES_HOST
export POSTGRES_PORT=YOUR_POSTGRES_PORT
export POSTGRES_DBNAME=YOUR_POSTGRES_DBNAME
Installing with Docker 🐳
Note: The R2R client must still be installed, even when running with Docker. Download the Python client with pip install r2r.
To run R2R using Docker:
docker pull emrgntcmplxty/r2r:latest
docker run -d \
--name r2r \
-p 8000:8000 \
-e POSTGRES_USER=$YOUR_POSTGRES_USER \
-e POSTGRES_PASSWORD=$YOUR_POSTGRES_PASSWORD \
-e POSTGRES_HOST=$YOUR_POSTGRES_HOST \
-e POSTGRES_PORT=$YOUR_POSTGRES_PORT \
-e POSTGRES_DBNAME=$YOUR_POSTGRES_DBNAME \
-e OPENAI_API_KEY=$YOUR_OPENAI_API_KEY \
emrgntcmplxty/r2r:latest
For local LLMs:
docker run -d \
--name r2r \
--add-host=host.docker.internal:host-gateway \
-p 8000:8000 \
-e POSTGRES_USER=$YOUR_POSTGRES_USER \
-e POSTGRES_PASSWORD=$YOUR_POSTGRES_PASSWORD \
-e POSTGRES_HOST=$YOUR_POSTGRES_HOST \
-e POSTGRES_PORT=$YOUR_POSTGRES_PORT \
-e POSTGRES_DBNAME=$YOUR_POSTGRES_DBNAME \
-e OLLAMA_API_BASE=http://host.docker.internal:11434 \
-e CONFIG_OPTION=local_ollama \
emrgntcmplxty/r2r:latest
R2R Quickstart
The following quickstart offers a step-by-step guide on running R2R locally as well as through the Python SDK. The guide ingests a list of provided provided documents and shows search, RAG, and advanced functionality. The script powering the quickstart can be found at r2r/examples/quickstart.py, and it can be configured and extended with sufficient developer familiarity.
Document Ingestion and Management
-
Ingest Files:
python -m r2r.examples.quickstart ingest_as_files -
View Document Info:
python -m r2r.examples.quickstart documents_overview -
View User Overview:
python -m r2r.examples.quickstart users_overview
Search and RAG Operations
-
Search Documents:
python -m r2r.examples.quickstart search --query="Who was Aristotle?" -
RAG Completion:
python -m r2r.examples.quickstart rag --query="What was Uber's profit in 2020?" -
Streaming RAG:
python -m r2r.examples.quickstart rag --query="What was Lyft's profit in 2020?" --streaming=true -
Hybrid Search RAG:
python -m r2r.examples.quickstart rag --query="Who is John Snow?" --do_hybrid_search
For more detailed examples and advanced features, please refer to our Quickstart Guide.
R2R Dashboard
Interact with R2R using our open-source React+Next.js dashboard. Check out the Dashboard Cookbook to get started!
Community and Support
- Discord: Chat live with maintainers and community members
- Github Issues: Report bugs and request features
Explore our R2R Docs for tutorials and cookbooks on various R2R features and integrations, including:
- Client-Server
- Multiple LLMs
- Knowledge Graph RAG
- Multimodal RAG
- Hybrid Search
- Local RAG
- Reranking
- Dashboard
Contributing
We welcome contributions of all sizes! Here's how you can help:
- Open a PR for new features, improvements, or better documentation.
- Submit a feature request or bug report