Spaces:
Paused
Paused
Commit
·
dfa2f23
1
Parent(s):
fbde303
Initial Docker Space
Browse files- Dockerfile +10 -0
- app.py +2 -2
Dockerfile
CHANGED
|
@@ -7,6 +7,16 @@ WORKDIR /app/chatbot
|
|
| 7 |
COPY requirements.txt .
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Copy source
|
| 11 |
COPY . .
|
| 12 |
|
|
|
|
| 7 |
COPY requirements.txt .
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
| 10 |
+
# Create writable directories
|
| 11 |
+
RUN mkdir -p /data/hf_cache /data/transformers_cache /data/nltk_data /data/audio
|
| 12 |
+
RUN chmod -R 777 /data
|
| 13 |
+
|
| 14 |
+
# Set environment variables
|
| 15 |
+
ENV HF_HOME=/data/hf_cache
|
| 16 |
+
ENV TRANSFORMERS_CACHE=/data/transformers_cache
|
| 17 |
+
ENV NLTK_DATA=/data/nltk_data
|
| 18 |
+
ENV AUDIO_FOLDER=/data/audio
|
| 19 |
+
|
| 20 |
# Copy source
|
| 21 |
COPY . .
|
| 22 |
|
app.py
CHANGED
|
@@ -16,7 +16,7 @@ app = Flask(__name__, static_folder="static")
|
|
| 16 |
CORS(app)
|
| 17 |
|
| 18 |
# Paths
|
| 19 |
-
AUDIO_FOLDER =
|
| 20 |
os.makedirs(AUDIO_FOLDER, exist_ok=True)
|
| 21 |
|
| 22 |
class ChatBot:
|
|
@@ -135,7 +135,7 @@ def chat_endpoint():
|
|
| 135 |
if not user_text:
|
| 136 |
return jsonify({"error": "Empty message"}), 400
|
| 137 |
resp_text, wav_name = asyncio.run(chatbot.chat(user_text, gender))
|
| 138 |
-
url = f"/
|
| 139 |
return jsonify({"response": resp_text, "audiofile": url})
|
| 140 |
|
| 141 |
@app.route('/static/audio/<path:filename>')
|
|
|
|
| 16 |
CORS(app)
|
| 17 |
|
| 18 |
# Paths
|
| 19 |
+
AUDIO_FOLDER = '/data/audio'
|
| 20 |
os.makedirs(AUDIO_FOLDER, exist_ok=True)
|
| 21 |
|
| 22 |
class ChatBot:
|
|
|
|
| 135 |
if not user_text:
|
| 136 |
return jsonify({"error": "Empty message"}), 400
|
| 137 |
resp_text, wav_name = asyncio.run(chatbot.chat(user_text, gender))
|
| 138 |
+
url = f"/audio/{wav_name}"
|
| 139 |
return jsonify({"response": resp_text, "audiofile": url})
|
| 140 |
|
| 141 |
@app.route('/static/audio/<path:filename>')
|