vihaan43 nsarrazin HF staff commited on
Commit
4b72857
β€’
0 Parent(s):

Duplicate from huggingchat/chat-ui-template

Browse files

Co-authored-by: Nathan Sarrazin <nsarrazin@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .env.local +36 -0
  2. .gitattributes +34 -0
  3. Dockerfile +60 -0
  4. README.md +12 -0
  5. entrypoint.sh +22 -0
.env.local ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MODELS=`[
2
+ {
3
+ "name": "Your Model",
4
+ "promptExamples": [
5
+ {
6
+ "title": "Python Fibonacci",
7
+ "prompt": "How can I write a Python function to generate the nth Fibonacci number?"
8
+ }, {
9
+ "title": "What is a meme?",
10
+ "prompt": "What is a meme, and what's the history behind this word?"
11
+ }, {
12
+ "title": "Regex",
13
+ "prompt": "Create a regex to extract dates from logs"
14
+ }
15
+ ],
16
+ "endpoints": [
17
+ {
18
+ "type": "tgi",
19
+ "url": "http://127.0.0.1:8080"
20
+ }
21
+ ],
22
+ "parameters": {
23
+ "temperature": 0.7,
24
+ "top_p": 0.95,
25
+ "repetition_penalty": 1.2,
26
+ "top_k": 50,
27
+ "truncate": 1000,
28
+ "max_new_tokens": 1024,
29
+ "stop": ["</s>", "<|>"]
30
+ }
31
+ }
32
+ ]`
33
+
34
+ PUBLIC_APP_NAME="Your ChatUI App"
35
+
36
+ MONGODB_URL=mongodb://localhost:27017
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ghcr.io/huggingface/chat-ui:latest AS base
2
+
3
+ FROM ghcr.io/huggingface/text-generation-inference:latest AS final
4
+
5
+ ARG MODEL_NAME
6
+ ENV MODEL_NAME=${MODEL_NAME}
7
+
8
+ ENV TZ=Europe/Paris \
9
+ PORT=3000
10
+
11
+ # mongo installation
12
+ RUN curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
13
+ gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
14
+ --dearmor
15
+
16
+ RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
17
+
18
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
19
+ mongodb-org && \
20
+ rm -rf /var/lib/apt/lists/*
21
+
22
+ # node installation
23
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash -
24
+
25
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
26
+ nodejs && \
27
+ rm -rf /var/lib/apt/lists/*
28
+
29
+ # image setup
30
+ RUN useradd -m -u 1000 user
31
+
32
+ RUN mkdir /app
33
+ RUN chown -R 1000:1000 /app
34
+ RUN mkdir /data
35
+ RUN chown -R 1000:1000 /data
36
+
37
+ # Switch to the "user" user
38
+ USER user
39
+
40
+ ENV HOME=/home/user \
41
+ PATH=/home/user/.local/bin:$PATH
42
+
43
+ RUN npm config set prefix /home/user/.local
44
+ RUN npm install -g dotenv-cli
45
+
46
+
47
+ # copy chat-ui from base image
48
+ COPY --from=base --chown=1000 /app/node_modules /app/node_modules
49
+ COPY --from=base --chown=1000 /app/package.json /app/package.json
50
+ COPY --from=base --chown=1000 /app/build /app/build
51
+
52
+ COPY --from=base --chown=1000 /app/.env /app/.env
53
+ COPY --chown=1000 .env.local /app/.env.local
54
+
55
+ COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
56
+
57
+ RUN chmod +x /app/entrypoint.sh
58
+
59
+ # entrypoint
60
+ ENTRYPOINT [ "/app/entrypoint.sh" ]
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Chat Ui Template
3
+ emoji: πŸš€
4
+ colorFrom: indigo
5
+ colorTo: blue
6
+ sdk: docker
7
+ pinned: false
8
+ app_port: 3000
9
+ suggested_hardware: a10g-small
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
entrypoint.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Make sure `/data/db` directory exists even with persistent storage
4
+ mkdir -p /data/db
5
+ # If app crashed, mongo didn't stop gracefully. Remove all the old *.lock files
6
+ find /data/db -name "*.lock" -type f -exec rm -f {} \;
7
+ # Start the local Mongo database
8
+ mongod &
9
+
10
+ # Start the text-generation-inference process
11
+ text-generation-launcher --model-id ${MODEL_NAME} --num-shard 1 --port 8080 --trust-remote-code &
12
+
13
+ # Wait for text-generation-inference to start
14
+ curl --retry 60 --retry-delay 10 --retry-connrefused http://127.0.0.1:8080/health
15
+
16
+ # Start the chat-ui process
17
+ dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000
18
+ # Wait for any process to exit
19
+ wait -n
20
+
21
+ # Exit with status of process that exited first
22
+ exit $?