๐ฅ Watch Demo Video - See the system in action!
This project implements a Retrieval-Augmented Generation (RAG) system using Langflow to create an AI assistant that can answer questions about UK benefits using information from the Citizens Advice website.
The system scrapes content from Citizens Advice Benefits pages, processes it into embeddings, stores it in a Chroma vector database, and uses Mistral AI to generate contextual responses to user queries about UK benefits.
Before setting up this project, you'll need:
-
API Keys:
- OpenAI API Key (for embeddings)
- Mistral AI API Key (for text generation)
-
System Requirements:
- macOS, Windows, or Linux
- At least 4GB RAM (recommended)
- Stable internet connection
The easiest way to get started is using Langflow Desktop:
-
Download Langflow Desktop:
- Visit Langflow Desktop
- Click "Download Langflow"
- Enter your contact information
- Download the appropriate version for your OS
-
Install the Application:
- macOS: Mount and install the downloaded
.dmgfile - Windows: Double-click the downloaded
.msifile and follow the installation wizard - Linux: Follow the platform-specific installation instructions
- macOS: Mount and install the downloaded
-
Launch Langflow:
- Open the Langflow application
- The interface should be available at
http://127.0.0.1:7860
If you prefer the Python package version:
-
Install Python 3.10-3.13 (3.10-3.12 for Windows)
-
Install uv package manager:
curl -LsSf https://astral.sh/uv/install.sh | sh -
Create a virtual environment:
uv venv langflow-env source langflow-env/bin/activate # On Windows: langflow-env\Scripts\activate
-
Install Langflow:
uv pip install langflow
-
Run Langflow:
uv run langflow run
-
Open Langflow Interface:
- Navigate to
http://127.0.0.1:7860in your browser - You should see the Langflow dashboard
- Navigate to
-
Import the Flow:
- Click on "My Projects" in the sidebar
- Click the "Add Flow" button
- Drag and drop the
Citizen Advice RAG.jsonfile from thelangflow_json/folder - The flow will be imported and appear in your projects list
-
Access Global Variables:
- In the Langflow interface, click on the settings icon (gear) in the top right
- Select "Global Variables" or "Environment Variables"
-
Add Required API Keys:
-
OpenAI API Key:
- Variable Name:
OPENAI_API_KEY - Value: Your OpenAI API key from platform.openai.com
- Variable Name:
-
Mistral API Key:
- Variable Name:
MISTRAL_API_KEY - Value: Your Mistral AI API key from console.mistral.ai
- Variable Name:
-
-
Save Configuration:
- Click "Save" to store your API keys
- The keys will be securely stored and used by the flow components
While deploying this prototype to the internet with cloud services and Docker is out of scope for this demonstration, you can still share your working prototype with colleagues and end users for valuable feedback using SMS integration.
This approach allows you to:
- Get real user feedback without complex deployment
- Test with actual end users in a familiar medium (text messages)
- Validate your prototype before investing in full deployment
- Gather insights on user needs and pain points
- Demonstrate value to stakeholders with working examples
Follow the detailed instructions in the twilio/ folder:
-
Install Dependencies:
pip install flask twilio python-dotenv requests
-
Set Up Twilio Account:
- Sign up for a free Twilio account at twilio.com
- Purchase a phone number (free trial available)
- Get your Account SID and Auth Token
-
Configure Environment Variables: Create a
.envfile in thetwilio/directory with your Twilio credentials -
Set Up ngrok for Local Development:
- Install and authenticate ngrok
- Use the provided
run_ngrok.shscript for easy setup
-
Configure Twilio Webhook:
- Point your Twilio phone number's webhook to your ngrok URL +
/webhook
- Point your Twilio phone number's webhook to your ngrok URL +
-
Run the Application:
- Start your Langflow server (port 7860)
- Start the Twilio webhook server (port 8888)
- Start ngrok tunnel
- User sends SMS to your Twilio phone number
- Twilio webhook receives the message
- API request is sent to your Langflow flow
- RAG system processes the question using Citizens Advice data
- Response is sent back to the user via SMS
Users can ask questions like:
- "What is Universal Credit?"
- "How do I apply for Housing Benefit?"
- "Am I eligible for Personal Independence Payment?"
- "What benefits are available for disabled people?"
The system will respond with helpful, contextual information from the Citizens Advice knowledge base.
- Low barrier to entry - Users just need to send a text message
- Real-world testing - Test with actual user scenarios
- Immediate feedback - Get responses and reactions quickly
- Cost-effective - Minimal setup costs compared to full deployment
- Scalable feedback - Easy to share with multiple stakeholders
For complete setup instructions, see the twilio/README.md file.
-
Open the Flow:
- Click on the "Citizen Advice RAG" project in your projects list
- The flow canvas will open showing the complete RAG pipeline
-
Initialize the System:
- The flow includes components for:
- URL Component: Scrapes content from Citizens Advice benefits pages
- Text Splitting: Breaks content into manageable chunks
- Embeddings: Converts text to vector representations using Mistral AI
- Chroma Database: Stores and retrieves relevant information
- Mistral Model: Generates responses based on retrieved context
- The flow includes components for:
-
Start the Playground:
- Click on the "Playground" tab in the interface
- This opens the chat interface where you can interact with the system
You can now ask questions about UK benefits, such as:
- "What is Universal Credit and how do I apply?"
- "Am I eligible for Housing Benefit?"
- "How does volunteering affect my benefits?"
- "What benefits are available for disabled people?"
- "How do I claim Child Benefit?"
- "What is Personal Independence Payment?"
The system will:
- Search the Citizens Advice knowledge base
- Retrieve relevant information
- Generate contextual, accurate responses
- Provide source information when available
The RAG system consists of several key components:
User Query โ Chat Input โ Chroma Search โ Context Retrieval โ Prompt Template โ Mistral Model โ Response
Key Components:
- URL Component: Scrapes Citizens Advice benefits pages
- SplitText: Breaks content into semantic chunks for better retrieval
- Mistral AI Embeddings: Creates vector representations of text
- Chroma Database: Stores embeddings and enables similarity search
- Prompt Template: Structures the context and question for the LLM
- Mistral Model: Generates human-like responses based on retrieved context
-
"No module named 'langflow.main'" Error:
- Use
uv run langflow runinstead oflangflow run - Reinstall with:
uv pip install langflow -U --force-reinstall
- Use
-
API Key Errors:
- Ensure API keys are correctly set in Global Variables
- Verify keys are valid and have sufficient credits
- Check for typos in variable names
-
Chroma Database Issues:
- Clear cache if needed: Delete contents of
~/.cache/langflow/ - Restart Langflow after clearing cache
- Clear cache if needed: Delete contents of
-
Performance Issues:
- Ensure you have at least 4GB RAM available
- Close other resource-intensive applications
- Consider using Langflow Desktop for better performance
Understanding the costs involved in running this RAG system:
- Cost: FREE ๐
- Langflow open-source version has no licensing fees
- Runs entirely on your local machine
- No cloud hosting costs
- Free Tier: Very generous
- Embeddings: Free tier includes substantial usage
- Text Generation: Free tier available with reasonable limits
- Paid Tier: Pay-as-you-go pricing when you exceed free limits
- Recommendation: Start with free tier - it's sufficient for testing and moderate usage
- Cost: Approximately $0.005 per query run
- Usage: Used for text embeddings in this flow
- Pricing: Based on token usage (very cost-effective for embeddings)
- Alternative: You can replace OpenAI embeddings with Mistral AI embeddings to reduce costs
- Free Trial: 15,000 free SMS messages
- Paid Tier: ~$0.0075 per SMS (US/UK numbers)
- Phone Number: ~$1/month per number
- Recommendation: Free trial is sufficient for prototyping and initial user testing
- Setup: $0 (Langflow OSS is free)
- Per Query: ~$0.005 (mainly OpenAI embeddings)
- Per SMS: ~$0.0075 (Twilio)
- Monthly (100 queries via SMS): ~$1.25
- Monthly (1000 queries via SMS): ~$12.50
- Use Mistral AI for both embeddings and generation to eliminate OpenAI costs
- Batch process queries when possible to reduce API calls
- Monitor usage through your API provider dashboards
- Set up usage alerts to avoid unexpected charges
- Consider caching frequently asked questions to reduce API calls
- Use Twilio free trial for initial prototyping and user testing
- Langflow Documentation
- Citizens Advice Benefits
- OpenAI API Documentation
- Mistral AI Documentation
- Technical RAG Documentation - Detailed explanation of how the RAG system works and how to build similar flows
This project demonstrates how to build a RAG system using Langflow in low code and now code environments which we think would be great for the charity sector to prototype and test new ideas. Feel free to:
- Modify the flow for different use cases
- Add new data sources
- Improve the prompt templates
- Share your improvements
This project is open source and available under the MIT License.
Note: This system is for educational and demonstration purposes. For official benefits advice, always consult with Citizens Advice or relevant government agencies.