Skip to content

redis-developer/llm-redisrail

Repository files navigation

Redis RAG with Rails

Contents

  1. Summary
  2. Architecture
  3. Features
  4. Prerequisites
  5. Installation
  6. Usage

Summary

This is a demo of usage of Redis as a vector store for Retrieval Augmented Generation (RAG) in two distinct scenarios:

  • Pure LangChain Expression Language (LCEL) chain with no safeguards on user or LLM interactions
  • NVIDIA NeMo-Guardrails implementation restricting both user inputs and LLM outputs Content from the Redis online documentation of Redis Vector Search is used for the RAG content. For the Guardrails implementation, questions and answers are restricted to the topic of Redis Vector Search.

Architecture

High-level Architecture

architecture

Application-level Architecture

app

Features

  • Redis Stack for the vector store
  • Python Bot server (Chainlit)
  • LangChain implementation of RAG with Redis
  • Parallel NVIDIA NeMo-Guardrails implementation of RAG with Redis

Prerequisites

  • Docker
  • Docker Compose
  • python3
  • git
  • pip

Installation

git clone https://github.com/redis-developer/llm-redisrail.git
cd llm-redisrail
python3 -m venv .venv
source .venv/bin/activate
pip install -qU python-dotenv redis bs4 langchain langchain_openai
  • Edit the .env_template file with your OpenAI key and rename the file to .env
  • By default, the guardrailed bot is executed. If you want a non-railed bot, change the MODE variable in docker-compose to 'chain'.

Usage

Environment Start Up

start.sh

Environment Shut Down

stop.sh