Spaces:
Running
Running
Add `chat-ui` and `chat-ui-db` docker images (#613)
Browse files* Add a `Dockerfile.local` image to build
* Add a build & publish workflow
* fix workflow
* Add support for local mongoDB
* Fix problem with POST requests
* use slim image
* Set mistral to be the default model in .env
* Fix entrypoint
* Revert change regarding config folder
* replace env variable by build arg for DB and update work
* old mention of `conf` folder in readme
* env to .env
* Revert readme changes
* lint
- .dockerignore +2 -0
- .env +30 -30
- conf/.env.ci → .env.ci +0 -0
- .github/workflows/build-image.yml +103 -0
- .github/workflows/lint-and-test.yml +1 -1
- .gitignore +3 -3
- Dockerfile.local +28 -0
- README.md +1 -1
- entrypoint.sh +23 -0
.dockerignore
CHANGED
@@ -6,3 +6,5 @@ LICENSE
|
|
6 |
README.md
|
7 |
node_modules/
|
8 |
.svelte-kit/
|
|
|
|
|
|
6 |
README.md
|
7 |
node_modules/
|
8 |
.svelte-kit/
|
9 |
+
.env*
|
10 |
+
!.env
|
.env
CHANGED
@@ -44,39 +44,39 @@ REJECT_UNAUTHORIZED=true
|
|
44 |
|
45 |
# 'name', 'userMessageToken', 'assistantMessageToken' are required
|
46 |
MODELS=`[
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
"
|
59 |
-
"
|
60 |
-
|
61 |
-
"
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
}
|
76 |
-
}
|
77 |
]`
|
|
|
78 |
OLD_MODELS=`[]`# any removed models, `{ name: string, displayName?: string, id?: string }`
|
79 |
-
TASK_MODEL=
|
80 |
|
81 |
PUBLIC_ORIGIN=#https://huggingface.co
|
82 |
PUBLIC_SHARE_PREFIX=#https://hf.co/chat
|
|
|
44 |
|
45 |
# 'name', 'userMessageToken', 'assistantMessageToken' are required
|
46 |
MODELS=`[
|
47 |
+
{
|
48 |
+
"name": "mistralai/Mistral-7B-Instruct-v0.1",
|
49 |
+
"displayName": "mistralai/Mistral-7B-Instruct-v0.1",
|
50 |
+
"description": "Mistral 7B is a new Apache 2.0 model, released by Mistral AI that outperforms Llama2 13B in benchmarks.",
|
51 |
+
"websiteUrl": "https://mistral.ai/news/announcing-mistral-7b/",
|
52 |
+
"preprompt": "",
|
53 |
+
"chatPromptTemplate" : "<s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{#if @root.preprompt}}{{@root.preprompt}}\n{{/if}}{{/if}}{{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s>{{/ifAssistant}}{{/each}}",
|
54 |
+
"parameters": {
|
55 |
+
"temperature": 0.1,
|
56 |
+
"top_p": 0.95,
|
57 |
+
"repetition_penalty": 1.2,
|
58 |
+
"top_k": 50,
|
59 |
+
"truncate": 3072,
|
60 |
+
"max_new_tokens": 1024,
|
61 |
+
"stop": ["</s>"]
|
62 |
+
},
|
63 |
+
"promptExamples": [
|
64 |
+
{
|
65 |
+
"title": "Write an email from bullet list",
|
66 |
+
"prompt": "As a restaurant owner, write a professional email to the supplier to get these products every week: \n\n- Wine (x10)\n- Eggs (x24)\n- Bread (x12)"
|
67 |
+
}, {
|
68 |
+
"title": "Code a snake game",
|
69 |
+
"prompt": "Code a basic snake game in python, give explanations for each step."
|
70 |
+
}, {
|
71 |
+
"title": "Assist in a task",
|
72 |
+
"prompt": "How do I make a delicious lemon cheesecake?"
|
73 |
+
}
|
74 |
+
]
|
75 |
}
|
|
|
76 |
]`
|
77 |
+
|
78 |
OLD_MODELS=`[]`# any removed models, `{ name: string, displayName?: string, id?: string }`
|
79 |
+
TASK_MODEL= # name of the model used for tasks such as summarizing title, creating query, etc.
|
80 |
|
81 |
PUBLIC_ORIGIN=#https://huggingface.co
|
82 |
PUBLIC_SHARE_PREFIX=#https://hf.co/chat
|
conf/.env.ci → .env.ci
RENAMED
File without changes
|
.github/workflows/build-image.yml
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Buid and Publish Image
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- "main"
|
7 |
+
pull_request:
|
8 |
+
branches:
|
9 |
+
- "*"
|
10 |
+
paths:
|
11 |
+
- "Dockerfile.local"
|
12 |
+
- "entrypoint.sh"
|
13 |
+
workflow_dispatch:
|
14 |
+
release:
|
15 |
+
types: [published, edited]
|
16 |
+
|
17 |
+
jobs:
|
18 |
+
build-and-publish-image-with-db:
|
19 |
+
runs-on: ubuntu-latest
|
20 |
+
steps:
|
21 |
+
- name: Checkout
|
22 |
+
uses: actions/checkout@v4
|
23 |
+
- name: Docker metadata
|
24 |
+
id: meta
|
25 |
+
uses: docker/metadata-action@v5
|
26 |
+
with:
|
27 |
+
images: |
|
28 |
+
ghcr.io/huggingface/chat-ui-db
|
29 |
+
tags: |
|
30 |
+
type=ref,event=branch
|
31 |
+
type=ref,event=pr
|
32 |
+
type=semver,pattern={{version}}
|
33 |
+
type=semver,pattern={{major}}
|
34 |
+
type=semver,pattern={{major}}.{{minor}}
|
35 |
+
|
36 |
+
- name: Set up QEMU
|
37 |
+
uses: docker/setup-qemu-action@v3
|
38 |
+
|
39 |
+
- name: Set up Docker Buildx
|
40 |
+
uses: docker/setup-buildx-action@v3
|
41 |
+
|
42 |
+
- name: Login to GitHub Container Registry
|
43 |
+
if: github.event_name != 'pull_request'
|
44 |
+
uses: docker/login-action@v3
|
45 |
+
with:
|
46 |
+
registry: ghcr.io
|
47 |
+
username: ${{ github.repository_owner }}
|
48 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
49 |
+
|
50 |
+
- name: Build and Publish Docker Image
|
51 |
+
uses: docker/build-push-action@v5
|
52 |
+
with:
|
53 |
+
context: .
|
54 |
+
file: Dockerfile.local
|
55 |
+
push: ${{ github.event_name != 'pull_request' }}
|
56 |
+
tags: ${{ steps.meta.outputs.tags }}
|
57 |
+
labels: ${{ steps.meta.outputs.labels }}
|
58 |
+
platforms: linux/amd64,linux/arm64
|
59 |
+
build-args: |
|
60 |
+
- INCLUDE_DB=true
|
61 |
+
build-and-publish-image-nodb:
|
62 |
+
runs-on: ubuntu-latest
|
63 |
+
steps:
|
64 |
+
- name: Checkout
|
65 |
+
uses: actions/checkout@v4
|
66 |
+
- name: Docker metadata
|
67 |
+
id: meta
|
68 |
+
uses: docker/metadata-action@v5
|
69 |
+
with:
|
70 |
+
images: |
|
71 |
+
ghcr.io/huggingface/chat-ui
|
72 |
+
tags: |
|
73 |
+
type=ref,event=branch
|
74 |
+
type=ref,event=pr
|
75 |
+
type=semver,pattern={{version}}
|
76 |
+
type=semver,pattern={{major}}
|
77 |
+
type=semver,pattern={{major}}.{{minor}}
|
78 |
+
|
79 |
+
- name: Set up QEMU
|
80 |
+
uses: docker/setup-qemu-action@v3
|
81 |
+
|
82 |
+
- name: Set up Docker Buildx
|
83 |
+
uses: docker/setup-buildx-action@v3
|
84 |
+
|
85 |
+
- name: Login to GitHub Container Registry
|
86 |
+
if: github.event_name != 'pull_request'
|
87 |
+
uses: docker/login-action@v3
|
88 |
+
with:
|
89 |
+
registry: ghcr.io
|
90 |
+
username: ${{ github.repository_owner }}
|
91 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
92 |
+
|
93 |
+
- name: Build and Publish Docker Image
|
94 |
+
uses: docker/build-push-action@v5
|
95 |
+
with:
|
96 |
+
context: .
|
97 |
+
file: Dockerfile.local
|
98 |
+
push: ${{ github.event_name != 'pull_request' }}
|
99 |
+
tags: ${{ steps.meta.outputs.tags }}
|
100 |
+
labels: ${{ steps.meta.outputs.labels }}
|
101 |
+
platforms: linux/amd64,linux/arm64
|
102 |
+
build-args: |
|
103 |
+
- INCLUDE_DB=false
|
.github/workflows/lint-and-test.yml
CHANGED
@@ -53,4 +53,4 @@ jobs:
|
|
53 |
steps:
|
54 |
- uses: actions/checkout@v3
|
55 |
- name: Build Docker image
|
56 |
-
run: docker build --secret id=DOTENV_LOCAL,src
|
|
|
53 |
steps:
|
54 |
- uses: actions/checkout@v3
|
55 |
- name: Build Docker image
|
56 |
+
run: docker build --secret id=DOTENV_LOCAL,src=.env.ci -t chat-ui:latest .
|
.gitignore
CHANGED
@@ -5,10 +5,10 @@ node_modules
|
|
5 |
/package
|
6 |
.env
|
7 |
.env.*
|
8 |
-
!.env.example
|
9 |
-
!.env.template
|
10 |
vite.config.js.timestamp-*
|
11 |
vite.config.ts.timestamp-*
|
12 |
SECRET_CONFIG
|
13 |
.idea
|
14 |
-
|
|
|
|
|
|
5 |
/package
|
6 |
.env
|
7 |
.env.*
|
|
|
|
|
8 |
vite.config.js.timestamp-*
|
9 |
vite.config.ts.timestamp-*
|
10 |
SECRET_CONFIG
|
11 |
.idea
|
12 |
+
!.env.ci
|
13 |
+
!.env
|
14 |
+
!.env.template
|
Dockerfile.local
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ARG INCLUDE_DB=false
|
2 |
+
FROM mongo:latest as mongo
|
3 |
+
|
4 |
+
FROM node:20-slim as local_db_false
|
5 |
+
|
6 |
+
FROM node:20-slim as local_db_true
|
7 |
+
|
8 |
+
RUN apt-get update
|
9 |
+
RUN apt-get install gnupg curl -y
|
10 |
+
|
11 |
+
COPY --from=mongo /usr/bin/mongo* /usr/bin/
|
12 |
+
|
13 |
+
FROM local_db_${INCLUDE_DB} as final
|
14 |
+
ARG INCLUDE_DB=false
|
15 |
+
ENV INCLUDE_DB=${INCLUDE_DB}
|
16 |
+
|
17 |
+
WORKDIR /app
|
18 |
+
|
19 |
+
COPY --link --chown=1000 package-lock.json package.json ./
|
20 |
+
RUN --mount=type=cache,target=/app/.npm \
|
21 |
+
npm set cache /app/.npm && \
|
22 |
+
npm ci
|
23 |
+
|
24 |
+
# copy the rest of the files, run regardless of
|
25 |
+
COPY --chown=1000 --link . .
|
26 |
+
RUN chmod +x /app/entrypoint.sh
|
27 |
+
|
28 |
+
CMD ["/bin/bash", "-c", "/app/entrypoint.sh"]
|
README.md
CHANGED
@@ -24,7 +24,7 @@ A chat interface using open source models, eg OpenAssistant or Llama. It is a Sv
|
|
24 |
5. [Deploying to a HF Space](#deploying-to-a-hf-space)
|
25 |
6. [Building](#building)
|
26 |
|
27 |
-
##
|
28 |
|
29 |
If you don't want to configure, setup, and launch your own Chat UI yourself, you can use this option as a fast deploy alternative.
|
30 |
|
|
|
24 |
5. [Deploying to a HF Space](#deploying-to-a-hf-space)
|
25 |
6. [Building](#building)
|
26 |
|
27 |
+
## No Setup Deploy
|
28 |
|
29 |
If you don't want to configure, setup, and launch your own Chat UI yourself, you can use this option as a fast deploy alternative.
|
30 |
|
entrypoint.sh
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if test -z "${DOTENV_LOCAL}" ; then
|
2 |
+
if ! test -f "/app/.env.local" ; then
|
3 |
+
echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. We are using the default .env config."
|
4 |
+
fi;
|
5 |
+
else
|
6 |
+
echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
|
7 |
+
cat <<< "$DOTENV_LOCAL" > /app/.env.local
|
8 |
+
fi;
|
9 |
+
|
10 |
+
if [ "$INCLUDE_DB" = "true" ] ; then
|
11 |
+
echo "INCLUDE_DB is set to true. Appending MONGODB_URL"
|
12 |
+
|
13 |
+
touch /app/.env.local
|
14 |
+
echo -e "\nMONGODB_URL=mongodb://localhost:27017" >> /app/.env.local
|
15 |
+
|
16 |
+
mkdir -p /data/db
|
17 |
+
mongod &
|
18 |
+
echo "Starting local MongoDB instance"
|
19 |
+
|
20 |
+
fi;
|
21 |
+
|
22 |
+
npm run build
|
23 |
+
npm run preview -- --host 0.0.0.0 --port 3000
|