Working docker setup
Browse files- Dockerfile +36 -0
- Makefile +7 -0
- bot.py +1 -0
- compose.yaml +8 -0
- scripts/bots/gradio_bot.py +1 -0
- scripts/gradio_ui.py +3 -1
Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10.2-slim-buster AS builder
|
| 2 |
+
|
| 3 |
+
RUN apt-get -y update
|
| 4 |
+
RUN apt-get -y install curl
|
| 5 |
+
|
| 6 |
+
RUN curl -sSL https://install.python-poetry.org | python3 -
|
| 7 |
+
RUN export PATH="/root/.local/bin:$PATH"
|
| 8 |
+
|
| 9 |
+
ENV POETRY_NO_INTERACTION=1 \
|
| 10 |
+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
| 11 |
+
POETRY_VIRTUALENVS_CREATE=1
|
| 12 |
+
|
| 13 |
+
WORKDIR /app
|
| 14 |
+
|
| 15 |
+
COPY pyproject.toml .
|
| 16 |
+
|
| 17 |
+
RUN /root/.local/bin/poetry install --no-interaction
|
| 18 |
+
|
| 19 |
+
FROM python:3.10.2-slim-buster AS runtime
|
| 20 |
+
|
| 21 |
+
WORKDIR app
|
| 22 |
+
|
| 23 |
+
ENV VIRTUAL_ENV="/app/.venv"
|
| 24 |
+
ENV PATH="/app/.venv/bin:$PATH"
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
| 28 |
+
|
| 29 |
+
COPY ./commons commons
|
| 30 |
+
COPY ./media media
|
| 31 |
+
COPY ./scripts scripts
|
| 32 |
+
COPY ./system_prompts system_prompts
|
| 33 |
+
|
| 34 |
+
COPY ./bot.py bot.py
|
| 35 |
+
|
| 36 |
+
EXPOSE 8080
|
Makefile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
default: build
|
| 2 |
+
|
| 3 |
+
build:
|
| 4 |
+
docker compose build --no-cache
|
| 5 |
+
|
| 6 |
+
deploy-local:
|
| 7 |
+
docker compose up --build
|
bot.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
|
| 2 |
if __name__ == '__main__':
|
|
|
|
| 3 |
from scripts.bots.gradio_bot import GradioBot
|
| 4 |
gradio_bot = GradioBot()
|
| 5 |
gradio_bot.start()
|
|
|
|
| 1 |
|
| 2 |
if __name__ == '__main__':
|
| 3 |
+
print("Starting gradio ui application ...")
|
| 4 |
from scripts.bots.gradio_bot import GradioBot
|
| 5 |
gradio_bot = GradioBot()
|
| 6 |
gradio_bot.start()
|
compose.yaml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
bot:
|
| 3 |
+
build: .
|
| 4 |
+
ports:
|
| 5 |
+
- "8080:8080"
|
| 6 |
+
entrypoint: ["python3", "bot.py"]
|
| 7 |
+
environment:
|
| 8 |
+
- OPENAI_API_KEY
|
scripts/bots/gradio_bot.py
CHANGED
|
@@ -18,4 +18,5 @@ class GradioBot:
|
|
| 18 |
gradio_bot = GradioBotUI(openai_bot, user_avatar=media_path("user.png"), agent_avatar=media_path("agent.png"))
|
| 19 |
|
| 20 |
def start(self):
|
|
|
|
| 21 |
self.gradio_bot.launch()
|
|
|
|
| 18 |
gradio_bot = GradioBotUI(openai_bot, user_avatar=media_path("user.png"), agent_avatar=media_path("agent.png"))
|
| 19 |
|
| 20 |
def start(self):
|
| 21 |
+
print("Starting gradio bot ...")
|
| 22 |
self.gradio_bot.launch()
|
scripts/gradio_ui.py
CHANGED
|
@@ -12,6 +12,7 @@ class GradioBotUI:
|
|
| 12 |
self.agent_avatar = agent_avatar
|
| 13 |
|
| 14 |
def launch(self):
|
|
|
|
| 15 |
with gr.Blocks() as demo:
|
| 16 |
with gr.Row():
|
| 17 |
gr.Markdown(
|
|
@@ -35,7 +36,8 @@ class GradioBotUI:
|
|
| 35 |
outputs=[prompt, chatbot], queue=False)
|
| 36 |
user_step.then(self.agent_message, inputs=[state, chatbot], outputs=[prompt, state, chatbot])
|
| 37 |
|
| 38 |
-
demo.launch()
|
|
|
|
| 39 |
|
| 40 |
def user_message(self, user_text, history):
|
| 41 |
return gr.Textbox(label="Prompt"), history + [[user_text, None]]
|
|
|
|
| 12 |
self.agent_avatar = agent_avatar
|
| 13 |
|
| 14 |
def launch(self):
|
| 15 |
+
print("Launching gradio ui ...")
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
with gr.Row():
|
| 18 |
gr.Markdown(
|
|
|
|
| 36 |
outputs=[prompt, chatbot], queue=False)
|
| 37 |
user_step.then(self.agent_message, inputs=[state, chatbot], outputs=[prompt, state, chatbot])
|
| 38 |
|
| 39 |
+
demo.launch(server_port=8080, server_name="0.0.0.0")
|
| 40 |
+
print("Done launching gradio ui!")
|
| 41 |
|
| 42 |
def user_message(self, user_text, history):
|
| 43 |
return gr.Textbox(label="Prompt"), history + [[user_text, None]]
|