https://github.com/amine-akrout/parenting-assistant-rag
AI-Powered Parenting Assistant
https://github.com/amine-akrout/parenting-assistant-rag
docker docker-compose faiss fastapi huggingface langchain langfuse llm llm-guard llmops openai rag
Last synced: about 2 months ago
JSON representation
AI-Powered Parenting Assistant
- Host: GitHub
- URL: https://github.com/amine-akrout/parenting-assistant-rag
- Owner: amine-akrout
- Created: 2025-01-02T13:30:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-10-01T07:10:51.000Z (8 months ago)
- Last Synced: 2025-10-01T09:12:18.313Z (8 months ago)
- Topics: docker, docker-compose, faiss, fastapi, huggingface, langchain, langfuse, llm, llm-guard, llmops, openai, rag
- Language: Python
- Homepage:
- Size: 1.52 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ค AI-Powered Parenting Assistant
## ๐ Overview
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.
---
## ๐ Features
### โ
**Retrieval-Augmented Generation (RAG) System**
- Uses **FAISS vector search** combined with **BM25 retrieval** for accurate contextual knowledge retrieval.
- Implements **OpenVINO Reranker** for document ranking and relevance filtering.
### ๐ก **AI Safety with LLM Guard**
- **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.
### โก **High-Performance AI Pipeline**
- **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**.
### ๐ฅ **Job-Worthy Tech Stack**
โ
**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
---
## ๐ Project Structure
```
๐ 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)
```
---
## ๐ Setup & Installation
### 1๏ธโฃ **Clone the Repository**
```bash
git clone https://github.com/amine-akrout/parenting_assistant_rag.git
cd parenting_assistant_rag
```
### 2๏ธโฃ **Create Virtual Environment & Install Dependencies**
```bash
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
```
### 3๏ธโฃ **Set Up Environment Variables**
Create a `.env` file in the root directory:
```ini
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
```
### 4๏ธโฃ **Run the API Server**
```bash
uvicorn src.api.main:app --host 0.0.0.0 --port 8000
```
### 5๏ธโฃ **Test the API**
Open **Swagger UI** to test endpoints:
๐ `http://localhost:8000/docs`
---
## ๐ณ Dockerized Workflow
This project includes a **Dockerized data pipeline** that prepares, indexes, and serves the chatbot API.
### 1๏ธโฃ **Start All Services**
```bash
docker-compose up --build
```
### 2๏ธโฃ **Stop All Services**
```bash
docker-compose down
```
### **Docker Services Overview**
- **`langfuse-server`** โ Logs chatbot requests/responses for monitoring
- **`db`** โ PostgreSQL database for logging and indexing
- **`clean-data`** โ Prepares and cleans datasets before indexing
- **`preprocess`** โ Creates FAISS/BM25 indexes for fast retrieval
- **`chatbot-api`** โ Runs the **FastAPI** chatbot backend
---
## ๐ Performance Monitoring (Langfuse)
Enable **Langfuse** for real-time monitoring:
๐ `http://localhost:3000`
View logs on **Langfuse Dashboard**.
---
## ๐งช Testing
Run unit tests using **pytest**:
```bash
pytest tests/
```
---
## ๐ฏ Future Enhancements
โ
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)
---
## ๐ค Contributing
Feel free to **open an issue** or **submit a pull request**.
---