Spaces:
Paused
Paused
correction requirements
Browse files- Dockerfile +18 -23
- rag_model.py +1 -1
- requirements-base.txt +7 -0
Dockerfile
CHANGED
@@ -1,43 +1,38 @@
|
|
|
|
1 |
FROM python:3.12-slim
|
2 |
|
3 |
-
#
|
4 |
RUN apt-get update && apt-get install -y \
|
5 |
build-essential \
|
6 |
cmake \
|
7 |
libopenblas-dev \
|
8 |
libsqlite3-dev \
|
9 |
-
git \
|
10 |
curl \
|
|
|
11 |
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
13 |
-
#
|
14 |
-
RUN useradd -m appuser
|
15 |
-
|
16 |
-
# Dossier de travail
|
17 |
WORKDIR /code
|
18 |
|
19 |
-
# Copier
|
20 |
-
COPY requirements.txt .
|
21 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
22 |
|
23 |
-
#
|
24 |
-
RUN
|
25 |
-
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
# Donner les droits
|
31 |
-
RUN chown -R appuser /code /home/appuser/nltk_data
|
32 |
|
33 |
-
#
|
34 |
-
|
35 |
|
36 |
-
#
|
37 |
-
|
38 |
|
39 |
-
#
|
40 |
EXPOSE 7860
|
41 |
|
42 |
-
# Commande de
|
43 |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
|
|
1 |
+
# ✅ Base image Python 3.12
|
2 |
FROM python:3.12-slim
|
3 |
|
4 |
+
# ✅ Installer dépendances système
|
5 |
RUN apt-get update && apt-get install -y \
|
6 |
build-essential \
|
7 |
cmake \
|
8 |
libopenblas-dev \
|
9 |
libsqlite3-dev \
|
|
|
10 |
curl \
|
11 |
+
git \
|
12 |
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
+
# ✅ Dossier de travail
|
|
|
|
|
|
|
15 |
WORKDIR /code
|
16 |
|
17 |
+
# ✅ Copier le fichier de requirements minimal (runtime only)
|
18 |
+
COPY requirements-base.txt .
|
|
|
19 |
|
20 |
+
# ✅ Forcer installation binaire pour éviter les compilations longues
|
21 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
22 |
+
pip install --no-cache-dir --only-binary=:all: --prefer-binary -r requirements-base.txt
|
23 |
|
24 |
+
# ✅ Télécharger les ressources NLTK dans un dossier accessible
|
25 |
+
RUN mkdir -p /root/nltk_data && \
|
26 |
+
python -m nltk.downloader -d /root/nltk_data punkt stopwords
|
|
|
|
|
27 |
|
28 |
+
# ✅ Définir la variable d'environnement pour NLTK
|
29 |
+
ENV NLTK_DATA=/root/nltk_data
|
30 |
|
31 |
+
# ✅ Copier le code
|
32 |
+
COPY . .
|
33 |
|
34 |
+
# ✅ Exposer le port (Streamlit)
|
35 |
EXPOSE 7860
|
36 |
|
37 |
+
# ✅ Commande de démarrage (adaptée Hugging Face)
|
38 |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
rag_model.py
CHANGED
@@ -111,7 +111,7 @@ Question reformulée :"""
|
|
111 |
|
112 |
def ask(self, question_raw: str) -> str:
|
113 |
logger.info(f"💬 Question reçue : {question_raw}")
|
114 |
-
if len(question_raw.split()) <=
|
115 |
context_sample, _ = self.retrieve_context(question_raw, top_k=3)
|
116 |
reformulated = self.reformulate_with_context(question_raw, context_sample)
|
117 |
else:
|
|
|
111 |
|
112 |
def ask(self, question_raw: str) -> str:
|
113 |
logger.info(f"💬 Question reçue : {question_raw}")
|
114 |
+
if len(question_raw.split()) <= 100:
|
115 |
context_sample, _ = self.retrieve_context(question_raw, top_k=3)
|
116 |
reformulated = self.reformulate_with_context(question_raw, context_sample)
|
117 |
else:
|
requirements-base.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==1.35.0
|
2 |
+
llama-cpp-python==0.3.14
|
3 |
+
sentence-transformers==2.5.1
|
4 |
+
llama-index==0.10.20
|
5 |
+
faiss-cpu==1.7.4
|
6 |
+
python-dotenv==1.1.1
|
7 |
+
nltk==3.8.1
|