This project implements an intelligent RAG (Retrieval-Augmented Generation) system using FireCrawl for web search capabilities and LlamaIndex for document processing. The system combines document retrieval with web search to provide comprehensive and accurate answers to user queries.
- Document Upload & Processing: Upload PDF documents for intelligent indexing
- Corrective RAG Workflow: Advanced workflow that combines document retrieval with web search
- FireCrawl Integration: Real-time web search capabilities for enhanced information retrieval
- Streamlit UI: User-friendly web interface for document upload and chat
- Multiple LLM Support: Compatible with OpenAI, Ollama, LMStudio, and other LLM providers
- Vector Storage: Uses Milvus for efficient document storage and retrieval
- Relevance Filtering: Intelligent filtering of retrieved documents for better accuracy
- LlamaIndex: Core RAG framework for document processing and retrieval
- FireCrawl: Web scraping and search API for real-time information
- Streamlit: Web application interface
- Milvus: Vector databases for document storage
- FastEmbed: High-performance embedding models
- OpenAI/Litellm: LLM integration for text generation
- Python 3.11 or later
- FireCrawl API key
- OpenAI API key (or other LLM provider)
- Sufficient disk space for document storage and caching
- Visit FireCrawl and sign up for an account
- Generate an API key from your dashboard
- Store it in your environment variables
- Visit OpenAI Platform and create an account
- Generate an API key
- Store it in your environment variables
Using pip:
pip install -r requirements.txtUsing uv (recommended):
uv syncCreate a .env file in the project root:
FIRECRAWL_API_KEY="your_firecrawl_api_key_here"
OPENAI_API_KEY="your_openai_api_key_here"streamlit run app.pypython start_server.pyjupyter notebook- Document Upload: Users upload PDF documents through the Streamlit interface
- Document Processing: Documents are processed, embedded, and stored in vector databases
- Query Processing: User queries are processed through the Corrective RAG workflow
- Retrieval: Relevant documents are retrieved from the vector store
- Web Search: If needed, FireCrawl performs web searches for additional information
- Answer Generation: The LLM generates comprehensive answers using both document and web content
- Relevance Filtering: Results are filtered for relevance to ensure accuracy
The Corrective RAG workflow consists of several key steps:
- Start Event: Initializes the workflow with user query
- Retrieve: Retrieves relevant documents from vector store
- Web Search: Performs web searches using FireCrawl when needed
- Query Processing: Combines document and web search results
- Answer Generation: Generates final response using LLM
firecrawl-agent/
├── app.py # Main Streamlit application
├── workflow.py # Corrective RAG workflow implementation
├── start_server.py # Server startup script
├── pyproject.toml # Project dependencies and configuration
├── requirements.txt # Python package requirements
├── assets/ # Images and animations
├── hf_cache/ # HuggingFace model cache
└── README.md # This file
The system supports various configuration options:
- LLM Models: OpenAI GPT-4, Ollama models, LMStudio, etc.
- Embedding Models: FastEmbed models (default: BAAI/bge-large-en-v1.5)
- Vector Stores: Milvus
- Timeout Settings: Configurable workflow execution timeouts
- Cache Settings: HuggingFace model caching and document caching
- API Key Errors: Ensure your FireCrawl and OpenAI API keys are correctly set
- Memory Issues: Large documents may require more memory; consider document chunking
- Timeout Errors: Increase timeout settings for complex queries
- Vector Store Issues: Clear storage directories if experiencing database corruption
Enable debug logging by setting verbose mode in the workflow initialization:
workflow = CorrectiveRAGWorkflow(
index=index,
firecrawl_api_key=api_key,
verbose=True, # Enable debug logging
llm=llm
)Contributions are welcome! Please feel free to submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
- LlamaIndex for the RAG framework
- Beam for deployment
- FireCrawl for web scraping capabilities
- Streamlit for the web interface
- Milvus for vector storage
