File size: 1,565 Bytes
8e66145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
FROM python:3.13-slim

WORKDIR /app

# Install git and git-lfs for downloading large files (if needed)
RUN apt-get update && \
    apt-get install -y git git-lfs && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Copy requirements file
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Download NLTK data
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('wordnet'); nltk.download('stopwords')"

# Create necessary directories
RUN mkdir -p data/users data/sessions data/conversations data/feedback
RUN mkdir -p mental_health_model_artifacts/chroma_db

# Copy application files
COPY api_mental_health.py .
COPY .env.example .env
COPY create_vector_db.py .

# Copy model artifacts if they exist, or they should be mounted/downloaded at runtime
# Note: For Hugging Face Spaces deployment, you'll need to use Git LFS or 
# provide a way to download these models at container startup
COPY mental_health_model_artifacts/ mental_health_model_artifacts/

# Create a startup script to handle potential model downloading
RUN echo '#!/bin/bash\n\
# Check if models exist\n\
if [ ! -f "mental_health_model_artifacts/crisis_classifier.pkl" ]; then\n\
    echo "Warning: Model artifacts not found. Please mount them or implement a download method."\n\
fi\n\
# Start the API server\n\
exec uvicorn api_mental_health:app --host 0.0.0.0 --port 7860\n\
' > /app/start.sh && chmod +x /app/start.sh

# Expose the port Hugging Face Spaces expects
EXPOSE 7860

# Use the startup script
CMD ["/app/start.sh"]