RAG with Memory¶
This guide demonstrates how to implement a RAG system with conversation memory using AdalFlow, based on our github_chat reference implementation.
Overview¶
The github_chat project is a practical RAG implementation that allows you to chat with GitHub repositories while maintaining conversation context. It demonstrates:
Code-aware responses using RAG
Memory management for conversation context
Support for multiple programming languages
Both web and command-line interfaces
Architecture¶
The system is built with several key components:
Data Pipeline¶
Input Documents → Text Splitter → Embedder → Vector Database
The data pipeline processes repository content through:
Document reading and preprocessing
Text splitting for optimal chunk sizes
Embedding generation
Storage in vector database
RAG System¶
User Query → RAG Component → [FAISS Retriever, Generator, Memory]
↓
Response
The RAG system includes:
FAISS-based retrieval for efficient similarity search
LLM-based response generation
Memory component for conversation history
Memory Management¶
The memory system maintains conversation context through:
Dialog turn tracking
Context preservation
Dynamic memory updates
This enables:
Follow-up questions
Reference to previous context
More coherent conversations
Quick Start¶
Installation:
git clone https://github.com/SylphAI-Inc/github_chat
cd github_chat
poetry install
Set up your OpenAI API key:
mkdir -p .streamlit
echo 'OPENAI_API_KEY = "your-key-here"' > .streamlit/secrets.toml
Run the application:
# Web interface
poetry run streamlit run app.py
# Repository analysis
poetry run streamlit run app_repo.py
Example Usage¶
Demo Version (app.py) - Ask about Alice (software engineer) - Ask about Bob (data scientist) - Ask about the company cafeteria - Test memory with follow-up questions
Repository Analysis (app_repo.py) - Enter your repository path - Click “Load Repository” - Ask questions about classes, functions, or code structure - View implementation details in expandable sections
Implementation Details¶
The system uses AdalFlow’s components:
core.embedder.Embedder
for document embeddingcore.retriever.Retriever
for similarity searchcore.generator.Generator
for response generationCustom memory management for conversation tracking
For detailed implementation examples, check out the github_chat repository.