A conversational AI assistant powered by RAG (Retrieval-Augmented Generation) technology to provide information about ENSA Al-Hoceima (École Nationale des Sciences Appliquées d'Al-Hoceima).
- Interactive chat interface built with Streamlit
- RAG-based responses using LangChain and Google Generative AI
- Vector storage with Qdrant for efficient information retrieval
- Comprehensive web scraping system for ENSAH website data
- Multi-language support
- Real-time information about:
- Academic programs and departments
- News and announcements
- Scientific activities
- Faculty members
- Administrative information
- General information about ENSAH
- Persistent chat history using MongoDB
- Maintains conversation context across sessions
- Stores user interactions and responses
- Enables personalized experiences
- Session Management
- Unique session IDs for each user
- Local storage integration for session persistence
- Stateful conversations across page refreshes
- Frontend: Streamlit
- Backend: FastAPI , LangServe
- Vector Database: QdrantDB (Cloud storage)
- LLM Integration: LangChain, Google Generative AI
- Web Scraping: BeautifulSoup4
- Data Storage: MongoDB (for chat history)
- Monitoring: LangSmith
- Containerization: Docker
ENSAH-RAG/
├── DataENG/ # English language data
├── DataFR/ # French language data (original data)
├── Image/ # Core RAG and API handlers
├── QdrantDB/ # Vector database storing scripts
├── RawData/ # Raw scraped data
├── Scrapers/ # Web scraping modules
├── assets/ # Static assets
├── app.py # Streamlit frontend
├── docker-compose.yml
├── requirements.txt
└── README.md
## 🚀 Getting Started
### Prerequisites
- Python 3.8+
- Docker and Docker Compose
- Google AI API key
- QdrantDB API key
- LangSmith API key
### Installation
1. Clone the repository:
```bash
git clone https://github.com/ELhadratiOth/ENSAH-ChatBot-RAG-APP
cd ENSAH-RAG
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
rename a
sample.envfile to.envand fill it with:
GOOGLE_API_KEY=GOOGLE_API_KEY
QDRANT_API_KEY=QDRANT_API_KEY
QDRANT_URL=QDRANT_URL
LANGSMITH_API_KEY=LANGSMITH_API_KEY
- Start the services using Docker Compose:
docker-compose up -d- Run the application:
streamlit run app.pyLocated in the Scrapers/ directory, includes modules for scraping:
- News and announcements
- Faculty information
- Academic programs
- Administrative information
- Scientific activities
- General information
The Image/ directory contains the core RAG implementation:
- Vector store management
- Chat history handling
- API endpoints
- Prompt templates
- Response generation
The Streamlit interface (app.py) provides:
- Chat interface
- Source attribution
- Session management
- Responsive design
Here are some screenshots of the ENSAH Assistant interface:
The system implements sophisticated chat history and session handling:
- Persistent storage of chat messages in MongoDB
- Each conversation is linked to a unique session ID
- Enables context-aware responses by maintaining conversation history
- Custom
LastNMessageHistoryimplementation for efficient history management
- Generates unique session IDs for each user
- Integrates with local storage for session persistence
- Maintains user context across page refreshes
- Seamless conversation continuity between visits
This robust history and session management enables:
- Context-aware conversations
- Personalized user experiences
- Consistent chat flow across sessions
- Improved response relevancy through historical context
Contributions are welcome! Please feel free to submit a Pull Request.



