8000 GitHub - shmily1012/R2R: SoTA production-ready AI retrieval system. Agentic Retrieval-Augmented Generation (RAG) with a RESTful API. · GitHub
[go: up one dir, main page]

Skip to content
shmily1012Public
forked from SciPhi-AI/R2R

About

SoTA production-ready AI retrieval system. Agentic Retrieval-Augmented Generation (RAG) with a RESTful API.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Screenshot 2025-03-27 at 6 35 02 AM

The most advanced AI retrieval system.

Agentic Retrieval-Augmented Generation (RAG) with a RESTful API.

About

R2R is an advanced AI retrieval system supporting Retrieval-Augmented Generation (RAG) with production-ready features. Built around a RESTful API, R2R offers multimodal content ingestion, hybrid search, knowledge graphs, and comprehensive document management.

R2R also includes a Deep Research API, a multi-step reasoning system that fetches relevant data from your knowledgebase and/or the internet to deliver richer, context-aware answers for complex queries.

Usage

# Basic search
results = client.retrieval.search(query="What is DeepSeek R1?")

# RAG with citations
response = client.retrieval.rag(query="What is DeepSeek R1?")

# Deep Research RAG Agent
response = client.retrieval.agent(
  message={"role":"user", "content": "What does deepseek r1 imply? Think about market, societal implications, and more."},
  rag_generation_config={
    "model": "anthropic/claude-3-7-sonnet-20250219",
    "extended_thinking": True,
    "thinking_budget": 4096,
    "temperature": 1,
    "top_p": None,
    "max_tokens_to_sample": 16000,
  },
)

Getting Started

# Quick install and run in light mode
pip install r2r
export OPENAI_API_KEY=sk-...
python -m r2r.serve

# Or run in full mode with Docker
# git clone git@github.com:SciPhi-AI/R2R.git && cd R2R
# export R2R_CONFIG_NAME=full OPENAI_API_KEY=sk-...
# docker compose -f compose.full.yaml --profile postgres up -d

For detailed self-hosting instructions, see the self-hosting docs.

Demo

demo_2x_comp.mp4

Using the API

1. Install SDK & Setup

# Install SDK
pip install r2r  # Python
# or
npm i r2r-js    # JavaScript

2. Client Initialization

from r2r import R2RClient
client = R2RClient(base_url="http://localhost:7272")
const { r2rClient } = require('r2r-js');
const client = new r2rClient("http://localhost:7272");

3. Document Operations

# Ingest sample or your own document
client.documents.create(file_path="/path/to/file")

# List documents
client.documents.list()

OpenAI-Compatible Gateway

R2R also exposes a lightweight OpenAI-compatible surface on /v1/*. Point OpenWebUI (or any OpenAI client) at http://<r2r-host>:7272/v1 with your R2R API key to call:

  • GET /v1/models for model discovery (mirrors the configured R2R models)
  • POST /v1/chat/completions for chat responses, including streaming support
  • POST /v1/embeddings for vector generation (float encoding only)
  • Chat completions run the full /v3/retrieval/rag pipeline under the hood, so answers include retrieval context and citation metadata.
  • The default published model id is ddr4_rag; override it with R2R_OPENAI_MODEL_ALIAS if you want a different name presented to OpenAI-compatible clients.

All requests reuse the existing R2R authentication headers (Bearer token or X-API-Key), so you can connect OpenWebUI as a tool or workspace without extra configuration.

Domain-Specific Launch Scripts

Need to run multiple knowledge bases on one machine? Minimal overrides live in py/r2r/configs/. Start the dedicated instances with:

# DDR4 knowledge base (defaults to port 8003)
./scripts/serve_ddr4.sh

# PCIe knowledge base (defaults to port 8002)
./scripts/serve_pcie.sh

Each script wires up a separate config (unique project name + Postgres database) before delegating to python -m r2r.serve. Override the port by exporting R2R_PORT or append additional CLI flags—they are forwarded.

Key Features

  • 📁 Multimodal Ingestion: Parse .txt, .pdf, .json, .png, .mp3, and more
  • 🔍 Hybrid Search: Semantic + keyword search with reciprocal rank fusion
  • 🔗 Knowledge Graphs: Automatic entity & relationship extraction
  • 🤖 Agentic RAG: Reasoning agent integrated with retrieval
  • 🔐 User & Access Management: Complete authentication & collection system

Community & Contributing

Our Contributors

About

SoTA production-ready AI retrieval system. Agentic Retrieval-Augmented Generation (RAG) with a RESTful API.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0