alymbeks commited on
Commit
e34a5a1
1 Parent(s): 165d46f

initial commit

Browse files
Files changed (2) hide show
  1. Dockerfile +39 -0
  2. README.md +129 -5
Dockerfile ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+ FROM node:19 as builder-production
4
+
5
+ RUN --mount=type=secret,id=GIT_TOKEN,mode=0444,required=true \
6
+ git clone https://$(cat /run/secrets/GIT_TOKEN)@github.com/d8a-ai/talk-doc-ui.git /app
7
+
8
+ WORKDIR /app
9
+
10
+ RUN --mount=type=cache,target=/app/.npm \
11
+ npm set cache /app/.npm && \
12
+ npm ci --omit=dev
13
+
14
+ FROM builder-production as builder
15
+
16
+ RUN --mount=type=cache,target=/app/.npm \
17
+ npm set cache /app/.npm && \
18
+ npm ci
19
+
20
+ COPY --link --chown=1000 . .
21
+
22
+ RUN --mount=type=secret,id=DOTENV_LOCAL,dst=.env.local \
23
+ npm --version
24
+ RUN --mount=type=secret,id=DOTENV_LOCAL,dst=.env.local \
25
+ npm run build
26
+
27
+ FROM nikolaik/python-nodejs
28
+
29
+ RUN npm install -g pm2
30
+
31
+ RUN --mount=type=secret,id=GIT_TOKEN,mode=0444,required=true \
32
+ git clone https://$(cat /run/secrets/GIT_TOKEN)@github.com/d8a-ai/talk-doc-ui.git /app
33
+ RUN pip install -r /app/requirements.txt
34
+
35
+ COPY --from=builder-production /app/node_modules /app/node_modules
36
+ COPY --from=builder /app/build /app/build
37
+ RUN echo $(ls /app)
38
+ RUN chown 1000 /app
39
+ CMD pm2 start /app/build/index.js -i $CPU_CORES --no-daemon
README.md CHANGED
@@ -1,10 +1,134 @@
1
  ---
2
- title: Talk Marketing Ui
3
- emoji:
4
- colorFrom: green
5
- colorTo: gray
6
  sdk: docker
7
  pinned: false
 
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: talk by d8a.ai
3
+ emoji: 🔥
4
+ colorFrom: blue
5
+ colorTo: blue
6
  sdk: docker
7
  pinned: false
8
+ license: apache-2.0
9
+ base_path: /
10
+ app_port: 3000
11
  ---
12
 
13
+ # Talk by d8a.ai
14
+
15
+ A chat interface using open source models, eg OpenAssistant. It is a SvelteKit app and it powers the [HuggingChat app on hf.co/chat](https://huggingface.co/chat).
16
+
17
+ 1. [Setup](#setup)
18
+ 2. [Launch](#launch)
19
+ 3. [Extra parameters](#extra-parameters)
20
+ 4. [Deploying to a HF Space](#deploying-to-a-hf-space)
21
+ 5. [Building](#building)
22
+
23
+ ## Setup
24
+
25
+ The default config for Chat UI is stored in the `.env` file. You will need to override some values to get Chat UI to run locally. This is done in `.env.local`.
26
+
27
+ Start by creating a `.env.local` file in the root of the repository. The bare minimum config you need to get Chat UI to run locally is the following:
28
+
29
+ ```bash
30
+ MONGODB_URL=<the URL to your mongoDB instance>
31
+ HF_ACCESS_TOKEN=<your access token>
32
+ ```
33
+
34
+ ### Database
35
+
36
+ The chat history is stored in a MongoDB instance, and having a DB instance available is needed for Chat UI to work.
37
+
38
+ You can use a local MongoDB instance. The easiest way is to spin one up using docker:
39
+
40
+ ```bash
41
+ docker run -d -p 27017:27017 --name mongo-chatui mongo:latest
42
+ ```
43
+
44
+ In which case the url of your DB will be `MONGODB_URL=mongodb://localhost:27017`.
45
+
46
+ Alternatively, you can use a [free MongoDB Atlas](https://www.mongodb.com/pricing) instance for this, Chat UI should fit comfortably within the free tier. After which you can set the `MONGODB_URL` variable in `.env.local` to match your instance.
47
+
48
+ ### Hugging Face Access Token
49
+
50
+ You will need a Hugging Face access token to run Chat UI locally, using the remote inference endpoints. You can get one from [your Hugging Face profile](https://huggingface.co/settings/tokens).
51
+
52
+ ## Launch
53
+
54
+ After you're done with the `.env.local` file you can run Chat UI locally with:
55
+
56
+ ```bash
57
+ npm install
58
+ npm run dev
59
+ ```
60
+
61
+ ## Extra parameters
62
+
63
+ ### OpenID connect
64
+
65
+ The login feature is disabled by default and users are attributed a unique ID based on their browser. But if you want to use OpenID to authenticate your users, you can add the following to your `.env.local` file:
66
+
67
+ ```bash
68
+ OPENID_PROVIDER_URL=<your OIDC issuer>
69
+ OPENID_CLIENT_ID=<your OIDC client ID>
70
+ OPENID_CLIENT_SECRET=<your OIDC client secret>
71
+ ```
72
+
73
+ These variables will enable the openID sign-in modal for users.
74
+
75
+ ### Custom models
76
+
77
+ You can customize the parameters passed to the model or even use a new model by updating the `MODELS` variable in your `.env.local`. The default one can be found in `.env` and looks like this :
78
+
79
+ ```json
80
+ MODELS=`[
81
+ {
82
+ "name": "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
83
+ "datasetName": "OpenAssistant/oasst1",
84
+ "description": "A good alternative to ChatGPT",
85
+ "websiteUrl": "https://open-assistant.io",
86
+ "userMessageToken": "<|prompter|>",
87
+ "assistantMessageToken": "<|assistant|>",
88
+ "messageEndToken": "</s>",
89
+ "preprompt": "Below are a series of dialogues between various people and an AI assistant. The AI tries to be helpful, polite, honest, sophisticated, emotionally aware, and humble-but-knowledgeable. The assistant is happy to help with almost anything, and will do its best to understand exactly what is needed. It also tries to avoid giving false or misleading information, and it caveats when it isn't entirely sure about the right answer. That said, the assistant is practical and really does its best, and doesn't let caution get too much in the way of being useful.\n-----\n",
90
+ "promptExamples": [
91
+ {
92
+ "title": "Write an email from bullet list",
93
+ "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)"
94
+ }, {
95
+ "title": "Code a snake game",
96
+ "prompt": "Code a basic snake game in python, give explanations for each step."
97
+ }, {
98
+ "title": "Assist in a task",
99
+ "prompt": "How do I make a delicious lemon cheesecake?"
100
+ }
101
+ ],
102
+ "parameters": {
103
+ "temperature": 0.9,
104
+ "top_p": 0.95,
105
+ "repetition_penalty": 1.2,
106
+ "top_k": 50,
107
+ "truncate": 1000,
108
+ "max_new_tokens": 1024
109
+ }
110
+ }
111
+ ]`
112
+ ```
113
+
114
+ You can change things like the parameters, or customize the preprompt to better suit your needs. You can also add more models by adding more objects to the array, with different preprompts for example.
115
+
116
+ ### Running your own models
117
+
118
+ If you want to, you can even run your own models, by having a look at our endpoint project, [text-generation-inference](https://github.com/huggingface/text-generation-inference). You can then add your own endpoint to the `MODELS` variable in `.env.local` and it will be picked up as well.
119
+
120
+ ## Deploying to a HF Space
121
+
122
+ Create a `DOTENV_LOCAL` secret to your HF space with the content of your .env.local, and they will be picked up automatically when you run.
123
+
124
+ ## Building
125
+
126
+ To create a production version of your app:
127
+
128
+ ```bash
129
+ npm run build
130
+ ```
131
+
132
+ You can preview the production build with `npm run preview`.
133
+
134
+ > To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.