An intelligent AI-powered car chatbot that helps you choose the best car for your preferences. It understands English, French, and Tunisian Dialect. Built with Flask, Groq (Llama 3), and Scikit-Learn.
# 🚗 Intelligent Automotive Chatbot
Welcome to the **Intelligent Automotive Chatbot**, an advanced AI-powered assistant designed to understand your car questions in **English**, **French**, or **Tunisian Dialect**.
Unlike basic bots, this system uses a **Large Language Model (LLM)** to grasp complex intents and an **Out-Of-Domain (OOD) Detector** to stay focused on its automotive expertise.
---
## 🏗️ Architecture & Flow (How it works?)
The application follows a robust "Retrieve & Generate" architecture. Here is the exact journey of a user request:
### 1. 📥 Input & Language Processing
- **File**: `app2.py` → `language_processor.py`
- **Action**: The user speaks. The system detects the language.
- **Magic**: If the user speaks in **Tunisian** (e.g., *"nheb karhba rkhissa"*), it is automatically translated to English (*"I want a cheap car"*) before being processed.
### 2. 🛡️ The Guardian (OOD Detection)
- **File**: `ood_detector.py`
- **Action**: Before using expensive resources, the system checks: *"Is this really about cars?"*
- **Technology**: Uses **TF-IDF Vectorization** + **One-Class SVM**.
- **Result**:
- "Pizza recipe?" ❌ Blocked immediately.
- "Price of a Toyota?" ✅ Passes to the Brain.
### 3. 🧠 The Brain (Intent Analysis)
- **File**: `llm_analyzer.py`
- **Technology**: **Groq API** (Llama-3.3-70B Model).
- **Action**: The LLM analyzes the text to extract structured data (JSON).
- **Example**:
- *Input*: "A cheap BMW"
- *Output*: `{"intent": "search", "entities": {"make": "bmw", "sort_order": "price_asc"}}`
### 4. 🔧 The Engine (Query Execution)
- **File**: `smart_query_builder.py`
- **Action**: Takes the structured JSON and builds a complex **Pandas** query to filter the `data/cars2.csv` file.
- **Capabilities**: Handles price, size, transmission filters, and generates a detailed catalog-style display.
---
## 🚀 Installation & Launch
1. **Install dependencies**:
```bash
pip install -r requirements.txt
```
2. **Configure usage environment**:
Create a …