OlivierDehaene commited on
Commit
985e74e
1 Parent(s): ea87893

Add chat ui + tgi + mongo dockerfile

Browse files
Files changed (3) hide show
  1. .env.local +72 -0
  2. Dockerfile +59 -0
  3. entrypoint.sh +16 -0
.env.local ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use .env.local to change these variables
2
+ # DO NOT EDIT THIS FILE WITH SENSITIVE DATA
3
+
4
+ MONGODB_URL=mongodb://localhost:27017
5
+ MONGODB_DB_NAME=chat-ui
6
+ MONGODB_DIRECT_CONNECTION=false
7
+
8
+ COOKIE_NAME=hf-chat
9
+ HF_ACCESS_TOKEN=#hf_<token> from from https://huggingface.co/settings/token
10
+
11
+ # used to activate search with web functionality. disabled if not defined
12
+ SERPAPI_KEY=#your serpapi key here
13
+
14
+ # Parameters to enable "Sign in with HF"
15
+ OPENID_CLIENT_ID=
16
+ OPENID_CLIENT_SECRET=
17
+ OPENID_SCOPES="openid profile" # Add "email" for some providers like Google that do not provide preferred_username
18
+ OPENID_PROVIDER_URL=https://huggingface.co # for Google, use https://accounts.google.com
19
+
20
+
21
+ # 'name', 'userMessageToken', 'assistantMessageToken' are required
22
+ MODELS=`[
23
+ {
24
+ "name": "OpenAssistant/falcon-7b-sft-top1-696",
25
+ "userMessageToken": "<|prompter|>",
26
+ "assistantMessageToken": "<|assistant|>",
27
+ "messageEndToken": "<|endoftext|>",
28
+ "preprompt": "",
29
+ "promptExamples": [
30
+ {
31
+ "title": "Python Fibonacci",
32
+ "prompt": "How can I write a Python function to generate the nth Fibonacci number?"
33
+ }, {
34
+ "title": "What is a meme?",
35
+ "prompt": "What is a meme, and what's the history behind this word?"
36
+ }, {
37
+ "title": "Regex",
38
+ "prompt": "Create a regex to extract dates from logs"
39
+ }
40
+ ],
41
+ "endpoints": [
42
+ {
43
+ "url": "http://localhost:8080"
44
+ }
45
+ ],
46
+ "parameters": {
47
+ "temperature": 0.2,
48
+ "top_p": 0.95,
49
+ "repetition_penalty": 1.2,
50
+ "top_k": 50,
51
+ "truncate": 1000,
52
+ "max_new_tokens": 1024
53
+ }
54
+ }
55
+ ]`
56
+ OLD_MODELS=`[]`# any removed models, `{ name: string, displayName?: string, id?: string }`
57
+
58
+ PUBLIC_ORIGIN=#https://huggingface.co
59
+ PUBLIC_SHARE_PREFIX=#https://hf.co/chat
60
+ PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable
61
+ PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID=#UA-XXXXXXXX-X / Leave empty to disable
62
+ PUBLIC_ANNOUNCEMENT_BANNERS=`[
63
+ {
64
+ "title": "Chat UI is now open sourced on GitHub",
65
+ "linkTitle": "GitHub repo",
66
+ "linkHref": "https://github.com/huggingface/chat-ui"
67
+ }
68
+ ]`
69
+
70
+ PARQUET_EXPORT_DATASET=
71
+ PARQUET_EXPORT_HF_TOKEN=
72
+ PARQUET_EXPORT_SECRET=
Dockerfile ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:19 as chatui-builder
2
+
3
+ WORKDIR /app
4
+
5
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
6
+ git && \
7
+ rm -rf /var/lib/apt/lists/*
8
+
9
+ RUN git clone https://github.com/huggingface/chat-ui.git
10
+
11
+ WORKDIR /app/chat-ui
12
+
13
+ RUN --mount=type=cache,target=/app/.npm \
14
+ npm set cache /app/.npm && \
15
+ npm ci
16
+
17
+ COPY .env.local .env.local
18
+ RUN npm run build
19
+
20
+ FROM ghcr.io/huggingface/text-generation-inference:latest
21
+
22
+ ENV TZ=Europe/Paris
23
+
24
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
25
+ gnupg \
26
+ curl && \
27
+ rm -rf /var/lib/apt/lists/*
28
+
29
+ RUN curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
30
+ gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
31
+ --dearmor
32
+
33
+ RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
34
+
35
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
36
+ mongodb-org && \
37
+ rm -rf /var/lib/apt/lists/*
38
+
39
+ RUN mkdir -p /data/db
40
+
41
+ RUN curl -fsSL https://deb.nodesource.com/setup_19.x | /bin/bash -
42
+
43
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
44
+ nodejs && \
45
+ rm -rf /var/lib/apt/lists/*
46
+
47
+ RUN npm install -g pm2
48
+ RUN mkdir /app
49
+
50
+ COPY --from=chatui-builder /app/chat-ui/node_modules /app/node_modules
51
+ COPY --from=chatui-builder /app/chat-ui/package.json /app/package.json
52
+ COPY --from=chatui-builder /app/chat-ui/build /app/build
53
+
54
+ COPY entrypoint.sh entrypoint.sh
55
+ RUN chmod +x entrypoint.sh
56
+
57
+ ENTRYPOINT ["./entrypoint.sh"]
58
+
59
+
entrypoint.sh ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Start the local Mongo database
4
+ mongod &
5
+
6
+ # Start the text-generation-inference process
7
+ text-generation-launcher --model-id OpenAssistant/falcon-7b-sft-top1-696 --num-shard 1 --port 8080 &
8
+
9
+ # Start the chat-ui process
10
+ pm2 start /app/build/index.js -i $CPU_CORES --no-daemon &
11
+
12
+ # Wait for any process to exit
13
+ wait -n
14
+
15
+ # Exit with status of process that exited first
16
+ exit $?