Prerequisites
Before you begin, make sure you have:- Python 3.8 or higher installed
- An OpenAI API key (get one here)
- A PDF document to test with
Quick Setup
Install dependencies
streamlit- Web interfacelangchain- RAG frameworklangchain-chroma- Vector databaselangchain-openai- OpenAI integrationpypdf- PDF processing
Configure your OpenAI API key
Create a Then edit
.env file from the example:.env and add your API key:Your First Query
Once the application is running, you can immediately start asking questions about your documents.Upload a PDF document
- In the sidebar, click the file uploader under “Upload de arquivos”
- Select one or more PDF files from your computer
- Wait for the processing to complete (you’ll see a “Carregando arquivos…” spinner)
- Extract text from your PDF using
PyPDFLoader - Split it into chunks (1000 characters with 400 character overlap)
- Create embeddings using OpenAI’s embedding model
- Store them in a local ChromaDB vector database
Select your AI model
Choose from the available models in the sidebar:
gpt-3.5-turbo- Fast and economicalgpt-4o-mini- Balanced performancegpt-4o- Most capablegpt-4-turboorgpt-4- Previous generation
Expected Output
When you ask a question, you’ll see:- Your question displayed in the chat interface
- A “Buscando resposta…” spinner while processing
- An AI response formatted in markdown with visualizations
The vector database persists in a local
db/ directory. Documents you upload remain available even after restarting the application.How It Works
Under the hood, RAG Chat uses a retrieval-augmented generation pipeline:- Retrieves relevant document chunks using similarity search
- Injects them into the prompt as context
- Maintains conversation history for follow-up questions
- Returns markdown-formatted responses
Next Steps
Installation
Learn about advanced installation options and troubleshooting
RAG Overview
Understand how the RAG pipeline works in detail
Configuration
Customize chunking, embeddings, and model settings
API Reference
Explore the core functions and their parameters