RAGtime

RAGtime is a minimal implementation of a Retrieval Augmented Generation (RAG) Pipeline designed to facilitate chatting with your documents

Stale Pure Nim score 23/100 · last commit 2025-04-11 · 2 stars · tests present · no docs generated

Summary

Latest Version Unknown
License Unknown
CI Status Failing
Stars 2
Forks 0
Open Issues 0
Last Commit 2025-04-11
Downloads 0
Last Indexed 2026-08-10 05:05

Installation

nimble install RAGtime
choosenim install RAGtime
git clone https://gitlab.com/tommaso.radicioni/pycon2024

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
RAGtime - - - - - - -

README

RAGtime - A Simple Pipeline for Chat with Your Docs

Index

Getting Started

Welcome to RAGtime, a minimal implementation of a Retrieval Augmented Generation (RAG) Pipeline designed to facilitate chatting with your documents. This project aims to provide an intuitive user interface for interacting with documents through a chat interface.

These instructions will guide you through setting up and running the RAGtime project on your local machine for development and testing purposes.

Prerequisites

Before you begin, ensure you have the following installed on your machine:

  • Docker
  • Docker Compose

If you don't have Docker installed, you can download it from Docker's official website.

Installation

  1. Clone the repository to your local machine:
git clone https://gitlab.com/tommaso.radicioni/pycon2024.git
cd pycon2024
  1. Add an .env file with your "HUGGINGFACE_API_KEY", "GROQ_API_KEY", and "OPENAI_API_KEY".

If you haven't already, sign up for a Hugging Face account by visiting Hugging Face's website. Fill out the registration form and complete the verification process. In your account dashboard, look for the "API Tokens" section. Here, you'll see an option to create a new token. Click on "New token".

Give your new token a descriptive name so you can remember its purpose later. Now that you have your API key, you can use it in this application to authenticate requests to Hugging Face services. Replace "HUGGINGFACE_API_KEY" with the actual API key you copied earlier.

To obtain a Groq OpenAI API key. Go to https://groq.ai/ and sign up for a Groq account if you don't already have one. Then, log in to your Groq account and navigate to the API keys section in your account settings. Finally, generate a new API key and copy the generated API key. To get your OpenAI API key, go to https://openai.com/, sign up for an account if you don't already have one, then navigate to the "API Keys" section in your dashboard. Click on "New API Key", give it a name like "RAGtime", and copy the generated API key.

  1. Build the Docker containers:

Navigate to the root directory of the cloned repository and execute the build script:

./build.sh

This script reads the docker-compose.yml file and builds the necessary Docker images for the Qdrant server and the Streamlit applications.

Running the Application

After successfully building the Docker containers, you can start the application by executing the start script:

./start.sh

This script starts the Docker containers defined in the docker-compose.yml file. Once the containers are up and running, you should be able to access the applications:

  • Haystack-based App: Navigate to http://localhost:8501 in your web browser.
  • LangChain-based App: Navigate to http://localhost:8503 in your web browser.

Technical Overview

Document Storage and Retrieval with Qdrant

Qdrant serves as the backbone for storing and retrieving document embeddings. Each document is transformed into a high-dimensional vector representation using advanced NLP models. These embeddings capture the semantic essence of the documents, allowing for precise and efficient similarity searches.

  • Document Embedding: Utilizing either HuggingFace API or OpenAI API, embeddings are generated for each document. These embeddings are then stored in Qdrant, ready for efficient retrieval.

  • Efficient Retrieval: When a user poses a question, its embedding is computed and used to query Qdrant for the most semantically similar document embeddings.

Building the RAG Pipeline with Haystack and LangChain

Haystack and LangChain orchestrate the entire process, from document embedding to answer generation, through a carefully constructed pipeline known as the Retrieval-Augmented Generation (RAG) pipeline.

  • RAG Pipeline Components: The pipeline consists of several interconnected components, including:
  • Text embedder for converting text to embeddings
  • Retriever for fetching relevant documents
  • Prompt builder for formatting prompts
  • Generator for producing candidate answers
  • Answer builder for constructing the final response

  • Dynamic Configuration: The pipeline is dynamically configurable, allowing for the selection of different embedding and generator models based on the requirements of the task at hand.

Codebase Explained

qdrant_document_store.py

This module defines a DocumentStore class that encapsulates the functionality needed to interact with a Qdrant document store. It handles document cleaning, splitting, embedding, and storage.

rag_retriever.py

Defines the RAGRetriever class, which constructs a RAG pipeline for retrieving relevant documents and generating answers to user queries.

rag_chat_utils.py

Defines the RAGChatAgent class, which integrates LangChain's components to manage chat history and interactions.

ragtime_langchain_app.py

Implements the LangChain-based Streamlit application. It uses the ChatAgent class to provide a conversational interface for interacting with documents.

ragtime_haystack_app.py

Sets up a Streamlit application that allows users to upload documents, which are then processed and stored using the DocumentStore. Users can interact with the stored documents through a chat interface powered by a Retrieval-Augmented Generation (RAG) model.

constants.py

Contains constant values used across the application, including:

  • Paths
  • Model names
  • Configuration settings for document splitting and retrieval
  • Language selections for chat interface

Docker Setup

The project includes Docker support for easy deployment and environment management.

  • docker-compose.yml: Defines services for the Qdrant server and the Streamlit applications. It specifies the images to use, port mappings, volume mounts, and environment variables.
  • build.sh: Script to build the Docker containers using the docker-compose.yml file.
  • start.sh: Script to start the Docker containers defined in docker-compose.yml.

Contact

For any inquiries or feedback, please open an issue on the GitLab repository or contact me directly here.