A Streamlit-based application that implements Corrective RAG (Retrieval-Augmented Generation) for processing and querying PDF documents using LangGraph.
- 📁 PDF Document Upload (up to 2 files)
- 🔍 Intelligent Query Processing
- 🌐 Web Search Integration
- 💡 Context-Aware Response Generation
- 📊 Document Relevance Grading
- 💬 Interactive Chat History
- Python 3.11
- OpenAI API Key
- Required Python packages (see
requirements.txt
) - SQLite needs to be > 3.35
-
Clone the repository: git clone [repository-url] cd [repository-name]
-
Install dependencies: docker compose up --build
-
Run the Streamlit application: streamlit run app.py
-
Open your web browser and navigate to the provided localhost URL
-
Upload PDF files (maximum 2)
-
Enter your OpenAI API key and Tavily API key
-
Process PDFs and start querying!
- PDF Upload Section: Handles document upload and management
- Query Interface: Process user prompts and generate responses
- Workflow Visualization: Shows processing stages
- Retrieve: Extract relevant documents from the knowledge base
- Query Processing: Analyze and understand user queries
- Relevance Check: Grade document relevance to query
- Web Search: Search external sources when needed
- Generate: Create final response
The application uses LangGraph to create a processing pipeline:
workflow = StateGraph(GraphState) workflow.add_node("retrieve", retrieve) workflow.add_node("grade_documents", grade_documents) workflow.add_node("generate", generate) workflow.add_node("transform_query", transform_query) workflow.add_node("web_search_node", web_search)
OPENAI_API_KEY
: Your OpenAI API keyTAVILY_API_KEY
: Your Tavily API key
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Based on the Corrective RAG paper
- Implementation inspired by RAG Implementation Guide