The AI-Powered Parenting Assistant is an intelligent chatbot designed to provide safe, reliable, and empathetic responses to parenting-related questions. Built using LangChain, LLM Guard, and FastAPI, the system leverages Retrieval-Augmented Generation (RAG) to enhance its responses with relevant knowledge from curated sources.
The chatbot also integrates advanced content filtering to ensure the safety and appropriateness of responses, making it a powerful demonstration of AI engineering best practices.
- Uses FAISS vector search combined with BM25 retrieval for accurate contextual knowledge retrieval.
- Implements OpenVINO Reranker for document ranking and relevance filtering.
- Input Filtering: Blocks toxic, political, religious, and self-harm topics using
llm_guard
. - Output Validation: Scans model responses for language safety, sensitivity, and relevance.
- Routing Mechanism: Ensures inappropriate queries are handled gracefully.
- LangChain Pipelines: Modular runnable chains for seamless data flow.
- Prompt Engineering: Optimized few-shot prompting for structured AI outputs.
- FastAPI Backend: Fully asynchronous REST API for real-time chatbot interactions.
- Langfuse Monitoring: Enables real-time LLM performance tracking.
✅ AI & LLMs: OpenAI GPT Models, LangChain, HuggingFace Embeddings
✅ Data Retrieval: FAISS, BM25, OpenVINO Reranker
✅ Safety: LLM Guard (Input & Output Filtering)
✅ Backend API: FastAPI, Pydantic, Loguru
✅ Monitoring: Langfuse Callbacks
✅ Dockerized Pipeline: Multi-stage AI data processing stack
📂 src/
├── core/
│ ├── chatbot.py # Main AI chatbot pipeline (LLM + Retrieval + Guard)
│ ├── embedding.py # FAISS/BM25 index generation
│ ├── evaluation.py # AI performance and accuracy checks
│ ├── filters.py # LLM Guard configurations for input/output scanning
│── config.py # Application settings & environment variables
│
├── api/
│ ├── routers/
│ │ └── chat.py # FastAPI routes for chatbot integration
│ │── __init__.py # API initializer
│ └── main.py # FastAPI app initialization
│
├── data/
│ ├── clean_data.py # Data preprocessing scripts
│
├── monitoring/
│ └── monitoring.py # Langfuse monitoring setup
│
├── Dockerfile # Containerization setup
├── docker-compose.yml # Multi-container deployment setup
├── requirements.txt # Python dependencies
├── README.md # Project documentation (this file)
git clone https://github.com/amine-akrout/parenting_assistant_rag.git
cd parenting_assistant_rag
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
Create a .env
file in the root directory:
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_DB=your_db_name
OPENAI_API_KEY=your-openai-key
LANGFUSE_PUBLIC_KEY=your-langfuse-public-key
LANGFUSE_SECRET_KEY=your-langfuse-secret-key
uvicorn src.api.main:app --host 0.0.0.0 --port 8000
Open Swagger UI to test endpoints:
📌 http://localhost:8000/docs
This project includes a Dockerized data pipeline that prepares, indexes, and serves the chatbot API.
docker-compose up --build
docker-compose down
langfuse-server
→ Logs chatbot requests/responses for monitoringdb
→ PostgreSQL database for logging and indexingclean-data
→ Prepares and cleans datasets before indexingpreprocess
→ Creates FAISS/BM25 indexes for fast retrievalchatbot-api
→ Runs the FastAPI chatbot backend
Enable Langfuse for real-time monitoring:
📌 http://localhost:3000
View logs on Langfuse Dashboard.
Run unit tests using pytest:
pytest tests/
✅ Add multi-turn conversations (memory support)
✅ Implement whisper model for speech-to-text
✅ Add more retrieval sources (vector & hybrid search)
✅ Integrate more LLM Guard features (e.g., sentiment analysis)
Feel free to open an issue or submit a pull request.