Graph RAG Reporting
Learn how to build a Graph RAG reporting application using the Perseus client.
This guide demonstrates how to leverage the Perseus client for building a powerful Graph RAG (Retrieval Augmented Generation) reporting application. You'll learn to convert a PDF document into a Markdown file using an LLM, construct a rich knowledge graph from its content, and then use this graph to generate insightful, context-aware reports.
Download the SDK
First, get the Perseus SDK and navigate to the example folder for Graph RAG reporting:
git clone https://github.com/Lettria/perseus-client.git
cd perseus-client/examples/advanced/graph-rag-reportingThis folder contains all the necessary templates and scripts to follow along with this tutorial.
Setup Environment
Ensure you have the required tools installed:
- Docker & Docker Compose 🐳
- Python 3.8+ 🐍
Copy the template environment file and fill in your credentials:
cp template.env .env| Variable | Description | Required |
|---|---|---|
LETTRIA_API_KEY | Your unique API key for the Lettria API. | Yes |
GEMINI_API_KEY | Your API key for the Gemini model. | Yes |
Install Dependencies & Start Services
Install Python dependencies
pip install -r requirements.txtThen, start the necessary Docker services:
docker compose up -d⏳ The embedder service may take a few minutes to fully boot on first run, as it needs to download the underlying model.
Convert PDF to Markdown
Transform your PDF document into Markdown format for easier processing:
python pdf_to_markdown.py assets/LOREAL_Rapport_Annuel_2024.pdfThis step uses an LLM to extract and structure the text content.
Index the Document
Create a knowledge graph from the Markdown file:
python index.py assets/LOREAL_Rapport_Annuel_2024.mdThis step extracts entities and relationships from the document and stores them in a structured graph.
Generate a Report
Query your knowledge graph to generate context-aware reports:
python report.py "What are the main activities of L'Oréal?"The output is a detailed, structured answer leveraging the graph’s connections.
Cleaning Up 🧹
When you’re done, stop and remove the Docker containers:
docker compose downThis frees up system resources and ensures a clean environment for next time.