Skip to content

Commit 9e21b43

Browse files
Chatbot RAG complet avec Admin et Docker
1 parent c5fc6c8 commit 9e21b43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2088
-1317
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
.Python
6+
env
7+
venv
8+
.venv
9+
pip-log.txt
10+
pip-delete-this-directory.txt
11+
.coverage
12+
.tox
13+
.pytest_cache
14+
.mypy_cache
15+
chatbot_data.db
16+
chatbot_production.db

.env.example

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# ============================================
2+
# Configuration Chatbot RAG (Production)
3+
# ============================================
4+
5+
# --- Info Application ---
6+
PROJECT_NAME="Chatbot RAG Production"
7+
API_V1_STR="/api/v1"
8+
9+
# --- Sécurité ---
10+
# IMPORTANT : Changez cette clé en production !
11+
# Générez-en une avec : openssl rand -hex 32
12+
SECRET_KEY="votre_cle_secrete_super_longue_et_aleatoire"
13+
ALGORITHM="HS256"
14+
ACCESS_TOKEN_EXPIRE_MINUTES=30
15+
16+
# --- Base de Données ---
17+
# Note : Dans Docker, utilisez le chemin absolu interne /app/data/
18+
# DATABASE_URL="sqlite:////app/data/chatbot_production.db"
19+
DATABASE_URL="sqlite:///./data/chatbot_production.db"
20+
21+
# --- Clés API LLM ---
22+
# Au moins une clé est requise. Groq est prioritaire.
23+
GROQ_API_KEY="gsk_votre_cle_api_groq_ici"
24+
OPENAI_API_KEY=""
25+
26+
# --- Configuration RAG ---
27+
EMBEDDING_MODEL="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
28+
FAQ_JSON_PATH="data/faq.json"
29+
CONFIDENCE_THRESHOLD=0.45

.github/workflows/test.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Chatbot CI
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
pull_request:
7+
branches: ["main", "master"]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# 1. Récupérer le code
15+
- uses: actions/checkout@v3
16+
17+
# 2. Installer Python
18+
- name: Set up Python 3.10
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.10"
22+
23+
# 3. Installer les dépendances
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
28+
pip install pytest httpx pytest-asyncio
29+
30+
# 4. Lancer les tests
31+
- name: Run Tests with Pytest
32+
# On définit des variables d'env bidons pour que Pydantic ne râle pas au démarrage
33+
env:
34+
GROQ_API_KEY: "mock_key"
35+
SECRET_KEY: "mock_secret"
36+
run: |
37+
pytest
38+
39+
docker-build:
40+
needs: test
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v3
44+
- name: Build Docker Image
45+
run: docker build . --file Dockerfile --tag chatbot-app:latest

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ cache/
2222

2323
# Environment variables
2424
.env
25-
.env.*
2625

2726
# Backup
2827
*.backup

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Utiliser une image Python officielle légère
2+
FROM python:3.10-slim
3+
4+
# Définir le répertoire de travail
5+
WORKDIR /app
6+
7+
# Variables d'environnement pour Python
8+
# PYTHONDONTWRITEBYTECODE: Évite les fichiers .pyc inutiles
9+
# PYTHONUNBUFFERED: Les logs s'affichent directement dans la console
10+
ENV PYTHONDONTWRITEBYTECODE=1 \
11+
PYTHONUNBUFFERED=1
12+
13+
# Installation des dépendances système (nécessaire pour certaines libs python)
14+
RUN apt-get update \
15+
&& apt-get install -y --no-install-recommends gcc python3-dev \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# Copier et installer les dépendances Python
19+
COPY requirements.txt .
20+
RUN pip install --no-cache-dir --upgrade pip \
21+
&& pip install --no-cache-dir -r requirements.txt
22+
23+
# Copier tout le code du projet dans le conteneur
24+
COPY . .
25+
26+
# Exposer le port 8000
27+
EXPOSE 8000
28+
29+
# Commande de lancement
30+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)