Spaces:
Sleeping
Sleeping
Commit ·
20efc7b
1
Parent(s): 5bb4004
Ensure cache is writtable
Browse filesFiles changed (2)
- Dockerfile+14-13
- app.py+3
12345678910111213141516171819202122232425262728293031FROM python:3.11-slim# Set environment variables (may need to change authority)ENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1# Create working directory (and authorised token)WORKDIR /app# Add to DockerfileENV TRANSFORMERS_CACHE=/app/model_cacheENV HF_HOME=/app/.cache/huggingfaceENV SENTENCE_TRANSFORMERS_HOME=/app/.cache/huggingface/sentence-transformers# Install SSL root certs and system deps required by pymongo + DNSRUN apt-get update && apt-get install -y --no-install-recommends \ca-certificates curl dnsutils gcc openssl && \rm -rf /var/lib/apt/lists/*# Copy and install dependenciesCOPY requirements.txt .RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt# Copy source code (app files)COPY . .# Expose the port used by UvicornEXPOSE 7860# Run the FastAPI application using UvicornCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "debug"]1234567891011121314151617181920212223242526272829303132FROM python:3.11-slim# Set environment variablesENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1 \TRANSFORMERS_CACHE=/app/model_cache \HF_HOME=/app/.cache/huggingface \SENTENCE_TRANSFORMERS_HOME=/app/.cache/huggingface/sentence-transformers# Create working directoryWORKDIR /app# Install system dependenciesRUN apt-get update && apt-get install -y --no-install-recommends \ca-certificates curl dnsutils gcc openssl && \rm -rf /var/lib/apt/lists/*# Install Python dependenciesCOPY requirements.txt .RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt# Create writable model cache directory to avoid permission errorRUN mkdir -p /app/model_cache /app/.cache/huggingface# Copy app source codeCOPY . .# Expose app portEXPOSE 7860# Run appCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "debug"]
114 unmodified lines11511611711811912015 unmodified lines1361371381391401413 unmodified lines145146147148149150114 unmodified lines@app.get("/")async def root() -> FileResponse:"""Serve the single‑page app."""return FileResponse(Path("statics/index.html"))15 unmodified linesquestion = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()if not question:raise ValueError("Empty transcription")# ── 2. LLM answerprompt = build_prompt(question)# Gemini Flash 2.5 – tuned for short latency3 unmodified linescontents=prompt)answer = response.text.strip()return JSONResponse({"question": question,114 unmodified lines11511611711811912012115 unmodified lines1371381391401411421433 unmodified lines147148149150151152153114 unmodified lines@app.get("/")async def root() -> FileResponse:"""Serve the single‑page app."""logger.info("[STATIC] Serving frontend")return FileResponse(Path("statics/index.html"))15 unmodified linesquestion = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()if not question:raise ValueError("Empty transcription")logger.info(f"[VOICE] Detected transcribe: {question}")# ── 2. LLM answerprompt = build_prompt(question)# Gemini Flash 2.5 – tuned for short latency3 unmodified linescontents=prompt)answer = response.text.strip()logger.info(f"[LLM] Decision answer: {answer}")return JSONResponse({"question": question,
Dockerfile+14-13
app.py+3