Skip to content

Commit

Permalink
Ccheng26/deployment (#34)
Browse files Browse the repository at this point in the history
add code for preventing chainlit server timeout and dockerfile for deployment
  • Loading branch information
ccheng26 authored Jun 6, 2024
1 parent 2d33765 commit dc9fb29
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
8 changes: 8 additions & 0 deletions 04-call-summaries/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__
*cache/
*.log
log/

*.DS_STORE

.git
34 changes: 34 additions & 0 deletions 04-call-summaries/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# syntax=docker/dockerfile:1.2

#====== Create builder image
FROM python:3.11-slim as builder

# create and activate virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

COPY requirements.txt .
# Use external cache to avoid fetching packages from the internet each time -- https://docs.docker.com/build/cache/#use-the-dedicated-run-cache
RUN --mount=type=cache,mode=0755,target=/root/.cache pip3 install -r requirements.txt

#====== Create final image
FROM python:3.11-slim as runner

# Set up a new user so we don't run as root
RUN useradd --create-home -u 1000 tron
RUN chown -R tron:tron /home/tron

USER tron
ENV HOME=/home/tron
WORKDIR $HOME/app

COPY --chown=tron --from=builder /opt/venv /opt/venv
# Activate virtual environment
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Ensure all messages always reach console
ENV PYTHONUNBUFFERED=1

EXPOSE 8000
HEALTHCHECK CMD curl http://localhost:8000 || exit 1
ENTRYPOINT ["chainlit", "run", "--port", "8000", "-h", "chainlit-call-summaries-bot.py"]
3 changes: 2 additions & 1 deletion 04-call-summaries/chainlit-call-summaries-bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ async def on_click_upload_file_query(action: cl.Action):
response = await run_summarization_technique(
technique=settings["summarization_technique"], transcript=transcript
)
print(response)
if settings["summarization_technique"] != "stuffing":
cl.sleep(1)
answer = f"Result:\n{response}"
await cl.Message(content=answer).send()

Expand Down

0 comments on commit dc9fb29

Please sign in to comment.