R2R Local System Installation

This guide will walk you through installing and running R2R on your local system without using Docker. This method allows for more customization and control over the R2R source code.

Prerequisites

Before starting, ensure you have the following installed and/or available in the cloud:

  • Python 3.12 or higher
  • pip (Python package manager)
  • Git
  • Postgres + pgvector

Install the R2R CLI and extra dependencies

First, install the R2R CLI with the additional light dependencies:

$pip install 'r2r[core,ingestion-bundle]'

The core and ingestion-bundle dependencies, combined with a Postgres database, provide the necessary components to deploy a user-facing R2R application into production.

If you need advanced features like orchestration or parsing with Unstructured.io then refer to the full installation .

Environment Setup

R2R requires connections to various services. Set up the following environment variables based on your needs:

Refer to the documentation here for detailed information on LLM configuration inside R2R.

$ # Set cloud LLM settings
> export OPENAI_API_KEY=sk-...
> # export ANTHROPIC_API_KEY=...
> # ...

Note, cloud providers are optional as R2R can be run entirely locally. For more information on local installation, refer here.

With R2R you can connect to your own instance of Postgres+pgvector or a remote cloud instance. Refer here for detailed documentation on configuring Postgres inside R2R.

$ # Set Postgres+pgvector settings
> export R2R_POSTGRES_USER=$YOUR_POSTGRES_USER
> export R2R_POSTGRES_PASSWORD=$YOUR_POSTGRES_PASSWORD
> export R2R_POSTGRES_HOST=$YOUR_POSTGRES_HOST
> export R2R_POSTGRES_PORT=$YOUR_POSTGRES_PORT
> export R2R_POSTGRES_DBNAME=$YOUR_POSTGRES_DBNAME
> export R2R_PROJECT_NAME=$YOUR_PROJECT_NAME # see note below

The R2R_PROJECT_NAME environment variable defines the tables within your Postgres database where the selected R2R project resides. If the required tables for R2R do not exist then they will be created by R2R during initialization.

If you are unfamiliar with Postgres then Supabase’s free cloud offering is a good place to start.

Running R2R

After installing the CLI and setting up your environment, you can start R2R using the following command:

$r2r serve

For local LLM usage:

$r2r serve --config-name=local_llm

Python Development Mode

For those looking to develop R2R locally:

  1. Install Poetry: Follow instructions on the official Poetry website.

  2. Clone and install dependencies:

    $git clone [email protected]:SciPhi-AI/R2R.git
    >cd R2R/py
    >poetry install -E "core ingestion-bundle"
  3. Setup environment: Follow the steps listed in the Environment Setup section above. Additionally, you may introduce a local .env file to make development easier, and you can customize your local r2r.toml to suit your specific needs.

  4. Start your server:

$poetry run r2r serve

Next Steps

After successfully installing R2R:

  1. Verify Installation: Ensure all components are running correctly by accessing the R2R API at http://localhost:7272/v3/health.

  2. Quick Start: Follow our R2R Quickstart Guide to set up your first RAG application.

  3. In-Depth Tutorial: For a more comprehensive understanding, work through our R2R Walkthrough.

  4. Customize Your Setup: Configure R2R components with the Configuration Guide.

If you encounter any issues during installation or setup, please use our Discord community or GitHub repository to seek assistance.

Built with