that1cooldude commited on
Commit
973a4e3
·
1 Parent(s): 28b24ad

Initial chat-ui deployment without binary files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +41 -0
  2. Dockerfile +32 -0
  3. chart/Chart.yaml +5 -0
  4. chart/env/prod.yaml +700 -0
  5. chart/templates/_helpers.tpl +22 -0
  6. chart/templates/config.yaml +10 -0
  7. chart/templates/deployment.yaml +81 -0
  8. chart/templates/hpa.yaml +45 -0
  9. chart/templates/infisical.yaml +24 -0
  10. chart/templates/ingress.yaml +32 -0
  11. chart/templates/network-policy.yaml +36 -0
  12. chart/templates/service-account.yaml +13 -0
  13. chart/templates/service-monitor.yaml +15 -0
  14. chart/templates/service.yaml +21 -0
  15. chart/values.yaml +67 -0
  16. docs/source/_toctree.yml +64 -0
  17. docs/source/configuration/common-issues.md +7 -0
  18. docs/source/configuration/embeddings.md +105 -0
  19. docs/source/configuration/metrics.md +9 -0
  20. docs/source/configuration/models/multimodal.md +24 -0
  21. docs/source/configuration/models/overview.md +147 -0
  22. docs/source/configuration/models/providers/anthropic.md +117 -0
  23. docs/source/configuration/models/providers/aws.md +35 -0
  24. docs/source/configuration/models/providers/cloudflare.md +35 -0
  25. docs/source/configuration/models/providers/cohere.md +26 -0
  26. docs/source/configuration/models/providers/google.md +92 -0
  27. docs/source/configuration/models/providers/langserve.md +22 -0
  28. docs/source/configuration/models/providers/llamacpp.md +49 -0
  29. docs/source/configuration/models/providers/ollama.md +39 -0
  30. docs/source/configuration/models/providers/openai.md +181 -0
  31. docs/source/configuration/models/providers/tgi.md +66 -0
  32. docs/source/configuration/models/tools.md +62 -0
  33. docs/source/configuration/open-id.md +16 -0
  34. docs/source/configuration/overview.md +10 -0
  35. docs/source/configuration/theming.md +18 -0
  36. docs/source/configuration/web-search.md +58 -0
  37. docs/source/developing/architecture.md +35 -0
  38. docs/source/developing/copy-huggingchat.md +71 -0
  39. docs/source/index.md +97 -0
  40. docs/source/installation/docker.md +11 -0
  41. docs/source/installation/helm.md +35 -0
  42. docs/source/installation/local.md +34 -0
  43. docs/source/installation/spaces.md +9 -0
  44. entrypoint.sh +19 -0
  45. models/add-your-models-here.txt +1 -0
  46. package.json +132 -0
  47. scripts/config.ts +64 -0
  48. scripts/populate.ts +391 -0
  49. scripts/samples.txt +194 -0
  50. scripts/setupTest.ts +49 -0
.gitignore ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Node dependencies
2
+ node_modules/
3
+
4
+ # Environment files
5
+ .env
6
+ .env.local
7
+ .env.*.local
8
+
9
+ # Build output
10
+ /build
11
+ /.svelte-kit
12
+
13
+ # IDE settings
14
+ .vscode
15
+ .idea
16
+
17
+ # Operating System Files
18
+ .DS_Store
19
+ Thumbs.db
20
+
21
+ # Binary files - avoid storing these in git
22
+ *.ttf
23
+ *.woff
24
+ *.woff2
25
+ *.eot
26
+ *.png
27
+ *.jpg
28
+ *.jpeg
29
+ *.gif
30
+ *.svg
31
+ *.ico
32
+ *.webp
33
+ *.mp3
34
+ *.mp4
35
+ *.webm
36
+ *.pdf
37
+ *.zip
38
+ *.tar
39
+ *.gz
40
+
41
+ # We'll use CDN fonts instead of local fonts
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18-alpine AS dependencies
2
+
3
+ # Install necessary packages for building
4
+ RUN apk add --no-cache git python3 make g++
5
+
6
+ WORKDIR /app
7
+ COPY package*.json ./
8
+ RUN npm install --legacy-peer-deps
9
+
10
+ FROM dependencies AS builder
11
+
12
+ WORKDIR /app
13
+ COPY . .
14
+ RUN npm run build
15
+
16
+ FROM node:18-alpine AS deploy
17
+
18
+ WORKDIR /app
19
+ COPY --from=dependencies /app/node_modules ./node_modules
20
+ COPY --from=builder /app/build ./build
21
+ COPY --from=builder /app/static ./static
22
+ COPY . .
23
+
24
+ # Set environment variables
25
+ ENV NODE_ENV=production
26
+ ENV PORT=3000
27
+
28
+ # Expose port
29
+ EXPOSE 3000
30
+
31
+ # Start command
32
+ CMD ["npm", "run", "preview", "--", "--port", "3000", "--host", "0.0.0.0"]
chart/Chart.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ apiVersion: v2
2
+ name: chat-ui
3
+ version: 0.0.1-latest
4
+ type: application
5
+ icon: https://huggingface.co/front/assets/huggingface_logo-noborder.svg
chart/env/prod.yaml ADDED
@@ -0,0 +1,700 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ image:
2
+ repository: huggingface
3
+ name: chat-ui
4
+
5
+ nodeSelector:
6
+ role-huggingchat: "true"
7
+
8
+ tolerations:
9
+ - key: "huggingface.co/huggingchat"
10
+ operator: "Equal"
11
+ value: "true"
12
+ effect: "NoSchedule"
13
+
14
+ serviceAccount:
15
+ enabled: true
16
+ create: true
17
+ name: huggingchat-prod
18
+
19
+ ingress:
20
+ path: "/chat"
21
+ annotations:
22
+ alb.ingress.kubernetes.io/healthcheck-path: "/healthcheck"
23
+ alb.ingress.kubernetes.io/listen-ports: "[{\"HTTP\": 80}, {\"HTTPS\": 443}]"
24
+ alb.ingress.kubernetes.io/group.name: "hub-prod"
25
+ alb.ingress.kubernetes.io/scheme: "internet-facing"
26
+ alb.ingress.kubernetes.io/ssl-redirect: "443"
27
+ alb.ingress.kubernetes.io/tags: "Env=prod,Project=hub,Terraform=true"
28
+ alb.ingress.kubernetes.io/target-node-labels: "role-hub-utils=true"
29
+ kubernetes.io/ingress.class: "alb"
30
+
31
+ envVars:
32
+ ADDRESS_HEADER: 'X-Forwarded-For'
33
+ ADMIN_CLI_LOGIN: "false"
34
+ ALTERNATIVE_REDIRECT_URLS: '["huggingchat://login/callback"]'
35
+ APP_BASE: "/chat"
36
+ ALLOW_IFRAME: "false"
37
+ COMMUNITY_TOOLS: "true"
38
+ COOKIE_SAMESITE: "lax"
39
+ COOKIE_SECURE: "true"
40
+ ENABLE_ASSISTANTS: "true"
41
+ ENABLE_ASSISTANTS_RAG: "true"
42
+ ENABLE_CONFIG_MANAGER: "false"
43
+ METRICS_PORT: 5565
44
+ LOG_LEVEL: "debug"
45
+ METRICS_ENABLED: "true"
46
+ MODELS: >
47
+ [
48
+ {
49
+ "name": "meta-llama/Llama-3.3-70B-Instruct",
50
+ "id": "meta-llama/Llama-3.3-70B-Instruct",
51
+ "description": "Ideal for everyday use. A fast and extremely capable model matching closed source models' capabilities. Now with the latest Llama 3.3 weights!",
52
+ "modelUrl": "https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct",
53
+ "websiteUrl": "https://llama.meta.com/",
54
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/meta-logo.png",
55
+ "tools": true,
56
+ "preprompt": "",
57
+ "parameters": {
58
+ "stop": ["<|endoftext|>", "<|eot_id|>"],
59
+ "temperature": 0.6,
60
+ "max_new_tokens": 1024,
61
+ "truncate": 7167
62
+ },
63
+ "promptExamples": [
64
+ {
65
+ "title": "Write an email",
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
+ {
69
+ "title": "Code a game",
70
+ "prompt": "Code a basic snake game in python, give explanations for each step."
71
+ },
72
+ {
73
+ "title": "Recipe help",
74
+ "prompt": "How do I make a delicious lemon cheesecake?"
75
+ }
76
+ ]
77
+ },
78
+ {
79
+ "name": "Qwen/Qwen3-235B-A22B",
80
+ "description": "Qwen's flagship model featuring optional reasoning. Exceptional performance with benchmarks rivaling R1 and o1.",
81
+ "modelUrl": "https://huggingface.co/Qwen/Qwen3-235B-A22B",
82
+ "websiteUrl": "https://qwenlm.github.io/blog/qwen3/",
83
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/qwen-logo.png",
84
+ "preprompt": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant.",
85
+ "reasoning": {
86
+ "type": "tokens",
87
+ "beginToken": "<think>",
88
+ "endToken": "</think>"
89
+ },
90
+ "parameters": {
91
+ "stop": ["<|endoftext|>", "<|im_end|>"],
92
+ "temperature": 0.6,
93
+ },
94
+ "promptExamples": [
95
+ {
96
+ "title": "Write an email",
97
+ "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) /nothink"
98
+ },
99
+ {
100
+ "title": "Build a website",
101
+ "prompt": "Generate a snazzy static landing page for a local coffee shop using HTML and CSS. You can use tailwind using <script src='https://cdn.tailwindcss.com'></script>."
102
+ },
103
+ {
104
+ "title": "Larger number",
105
+ "prompt": "9.11 or 9.9 which number is larger?"
106
+ },
107
+ ],
108
+ "endpoints": [
109
+ {
110
+ "type": "openai",
111
+ "baseURL": "https://internal.api-inference.huggingface.co/models/Qwen/Qwen3-235B-A22B/v1"
112
+ }
113
+ ]
114
+ },
115
+ {
116
+ "name": "Qwen/Qwen2.5-72B-Instruct",
117
+ "description": "The latest Qwen open model with improved role-playing, long text generation and structured data understanding.",
118
+ "modelUrl": "https://huggingface.co/Qwen/Qwen2.5-72B-Instruct",
119
+ "websiteUrl": "https://qwenlm.github.io/blog/qwen2.5/",
120
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/qwen-logo.png",
121
+ "preprompt": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant.",
122
+ "parameters": {
123
+ "stop": ["<|endoftext|>", "<|im_end|>"],
124
+ "temperature": 0.6,
125
+ "truncate": 28672,
126
+ "max_new_tokens": 3072
127
+ },
128
+ "tools": true,
129
+ "promptExamples": [
130
+ {
131
+ "title": "Write an email",
132
+ "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)"
133
+ },
134
+ {
135
+ "title": "Code a game",
136
+ "prompt": "Code a basic snake game in python, give explanations for each step."
137
+ },
138
+ {
139
+ "title": "Recipe help",
140
+ "prompt": "How do I make a delicious lemon cheesecake?"
141
+ }
142
+ ]
143
+ },
144
+ {
145
+ "name": "CohereForAI/c4ai-command-r-plus-08-2024",
146
+ "description": "Cohere's largest language model, optimized for conversational interaction and tool use. Now with the 2024 update!",
147
+ "modelUrl": "https://huggingface.co/CohereForAI/c4ai-command-r-plus-08-2024",
148
+ "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
149
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
150
+ "tools": true,
151
+ "parameters": {
152
+ "stop": ["<|END_OF_TURN_TOKEN|>", "<|im_end|>"],
153
+ "truncate": 28672,
154
+ "max_new_tokens": 2048,
155
+ "temperature": 0.3
156
+ },
157
+ "promptExamples": [
158
+ {
159
+ "title": "Generate image",
160
+ "prompt": "Generate the portrait of a scientific mouse in its laboratory."
161
+ },
162
+ {
163
+ "title": "Review code",
164
+ "prompt": "Review this pull request: https://github.com/huggingface/chat-ui/pull/1131/files"
165
+ },
166
+ {
167
+ "title": "Code a game",
168
+ "prompt": "Code a basic snake game in python, give explanations for each step."
169
+ }
170
+ ]
171
+ },
172
+ {
173
+ "name": "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
174
+ "modelUrl": "https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
175
+ "websiteUrl": "https://deepseek.com/",
176
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/deepseek-logo.png",
177
+ "description": "The first reasoning model from DeepSeek, distilled into a 32B dense model. Outperforms o1-mini on multiple benchmarks.",
178
+ "reasoning": {
179
+ "type": "tokens",
180
+ "beginToken": "",
181
+ "endToken": "</think>"
182
+ },
183
+ "promptExamples": [
184
+ {
185
+ "title": "Rs in strawberry",
186
+ "prompt": "how many R in strawberry?"
187
+ },
188
+ {
189
+ "title": "Larger number",
190
+ "prompt": "9.11 or 9.9 which number is larger?"
191
+ },
192
+ {
193
+ "title": "Measuring 6 liters",
194
+ "prompt": "I have a 6- and a 12-liter jug. I want to measure exactly 6 liters."
195
+ }
196
+ ],
197
+ "endpoints": [
198
+ {
199
+ "type": "openai",
200
+ "baseURL": "https://internal.api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B/v1"
201
+ }
202
+ ]
203
+ },
204
+ {
205
+ "name": "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
206
+ "modelUrl": "https://huggingface.co/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
207
+ "websiteUrl": "https://www.nvidia.com/",
208
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/nvidia-logo.png",
209
+ "description": "Nvidia's latest Llama fine-tune, topping alignment benchmarks and optimized for instruction following.",
210
+ "parameters": {
211
+ "stop": ["<|eot_id|>", "<|im_end|>"],
212
+ "temperature": 0.5,
213
+ "truncate": 28672,
214
+ "max_new_tokens": 2048
215
+ },
216
+ "promptExamples": [
217
+ {
218
+ "title": "Rs in strawberry",
219
+ "prompt": "how many R in strawberry?"
220
+ },
221
+ {
222
+ "title": "Larger number",
223
+ "prompt": "9.11 or 9.9 which number is larger?"
224
+ },
225
+ {
226
+ "title": "Measuring 6 liters",
227
+ "prompt": "I have a 6- and a 12-liter jug. I want to measure exactly 6 liters."
228
+ }
229
+ ],
230
+ "endpoints": [
231
+ {
232
+ "type": "openai",
233
+ "baseURL": "https://internal.api-inference.huggingface.co/models/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF/v1"
234
+ }
235
+ ]
236
+ },
237
+ {
238
+ "name": "Qwen/QwQ-32B",
239
+ "preprompt": "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step.",
240
+ "modelUrl": "https://huggingface.co/Qwen/QwQ-32B",
241
+ "websiteUrl": "https://qwenlm.github.io/blog/qwq-32b/",
242
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/qwen-logo.png",
243
+ "description": "QwQ is the latest reasoning model released by the Qwen team, approaching the capabilities of R1 in benchmarks.",
244
+ "reasoning": {
245
+ "type": "tokens",
246
+ "beginToken": "",
247
+ "endToken": "</think>"
248
+ },
249
+ "promptExamples": [
250
+ {
251
+ "title": "Rs in strawberry",
252
+ "prompt": "how many R in strawberry?"
253
+ },
254
+ {
255
+ "title": "Larger number",
256
+ "prompt": "9.11 or 9.9 which number is larger?"
257
+ },
258
+ {
259
+ "title": "Measuring 6 liters",
260
+ "prompt": "I have a 6- and a 12-liter jug. I want to measure exactly 6 liters."
261
+ }
262
+ ],
263
+ "endpoints": [
264
+ {
265
+ "type": "openai",
266
+ "baseURL": "https://atv7xs1nxxtx2wl0.us-east-1.aws.endpoints.huggingface.cloud/v1"
267
+ }
268
+ ]
269
+ },
270
+ {
271
+ "name": "google/gemma-3-27b-it",
272
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/google-logo.png",
273
+ "multimodal": true,
274
+ "description": "Google's latest open model with great multilingual performance, supports image inputs natively.",
275
+ "websiteUrl": "https://blog.google/technology/developers/gemma-3/",
276
+ "promptExamples": [
277
+ {
278
+ "title": "Write an email",
279
+ "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)"
280
+ },
281
+ {
282
+ "title": "Code a game",
283
+ "prompt": "Code a basic snake game in python, give explanations for each step."
284
+ },
285
+ {
286
+ "title": "Recipe help",
287
+ "prompt": "How do I make a delicious lemon cheesecake?"
288
+ }
289
+ ],
290
+ "endpoints": [
291
+ {
292
+ "type": "openai",
293
+ "baseURL": "https://wp0d3hn6s3k8jk22.us-east-1.aws.endpoints.huggingface.cloud/v1",
294
+ "multimodal": {
295
+ "image": {
296
+ "maxSizeInMB": 10,
297
+ "maxWidth": 560,
298
+ "maxHeight": 560,
299
+ "supportedMimeTypes": ["image/jpeg"],
300
+ "preferredMimeType": "image/jpeg"
301
+ }
302
+ }
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ "name": "mistralai/Mistral-Small-3.1-24B-Instruct-2503",
308
+ "displayName": "mistralai/Mistral-Small-3.1-24B-Instruct-2503",
309
+ "description": "A small model with good capabilities in language understanding and commonsense reasoning.",
310
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/mistral-logo.png",
311
+ "websiteUrl": "https://mistral.ai/news/mistral-nemo/",
312
+ "modelUrl": "https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503",
313
+ "preprompt": "",
314
+ "promptExamples": [
315
+ {
316
+ "title": "Write an email",
317
+ "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)"
318
+ },
319
+ {
320
+ "title": "Code a game",
321
+ "prompt": "Code a basic snake game in python, give explanations for each step."
322
+ },
323
+ {
324
+ "title": "Recipe help",
325
+ "prompt": "How do I make a delicious lemon cheesecake?"
326
+ }
327
+ ],
328
+
329
+ "endpoints": [
330
+ {
331
+ "type": "openai",
332
+ "baseURL": "https://hkjfqcryevvq9cie.us-east-1.aws.endpoints.huggingface.cloud/v1"
333
+ }
334
+ ]
335
+ },
336
+ {
337
+ "name": "Qwen/Qwen2.5-VL-32B-Instruct",
338
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/qwen-logo.png",
339
+ "description": "The latest multimodal model from Qwen! Supports image inputs natively.",
340
+ "websiteUrl": "https://qwenlm.github.io/blog/qwen2.5-vl/",
341
+ "modelUrl": "https://huggingface.co/Qwen/Qwen2.5-VL-32B-Instruct",
342
+ "multimodal": true,
343
+ "promptExamples": [
344
+ {
345
+ "title": "Write an email",
346
+ "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)"
347
+ },
348
+ {
349
+ "title": "Code a game",
350
+ "prompt": "Code a basic snake game in python, give explanations for each step."
351
+ },
352
+ {
353
+ "title": "Recipe help",
354
+ "prompt": "How do I make a delicious lemon cheesecake?"
355
+ }
356
+ ],
357
+ "endpoints": [
358
+ {
359
+ "type": "openai",
360
+ "baseURL": "https://lf91qeosuambouj4.us-east-1.aws.endpoints.huggingface.cloud/v1",
361
+ "multimodal": {
362
+ "image": {
363
+ "maxSizeInMB": 10,
364
+ "maxWidth": 1024,
365
+ "maxHeight": 1024,
366
+ "supportedMimeTypes": ["image/png", "image/jpeg", "image/webp"],
367
+ "preferredMimeType": "image/webp"
368
+ }
369
+ }
370
+ }
371
+ ]
372
+ },
373
+ {
374
+ "name": "microsoft/Phi-4",
375
+ "description": "One of the best small models, super fast for simple tasks.",
376
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/microsoft-logo.png",
377
+ "modelUrl": "https://huggingface.co/microsoft/Phi-4",
378
+ "websiteUrl": "https://techcommunity.microsoft.com/blog/aiplatformblog/introducing-phi-4-microsoft%E2%80%99s-newest-small-language-model-specializing-in-comple/4357090",
379
+ "preprompt": "",
380
+ "parameters": {
381
+ "stop": ["<|end|>", "<|endoftext|>", "<|assistant|>"],
382
+ "temperature": 0.6,
383
+ "truncate": 28672,
384
+ "max_new_tokens": 3072
385
+ },
386
+ "promptExamples": [
387
+ {
388
+ "title": "Write an email",
389
+ "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)"
390
+ },
391
+ {
392
+ "title": "Code a game",
393
+ "prompt": "Code a basic snake game in python, give explanations for each step."
394
+ },
395
+ {
396
+ "title": "Recipe help",
397
+ "prompt": "How do I make a delicious lemon cheesecake?"
398
+ }
399
+ ],
400
+ "endpoints": [
401
+ {
402
+ "type": "openai",
403
+ "baseURL": "https://up5ijetg6a2e9zlb.us-east-1.aws.endpoints.huggingface.cloud/v1"
404
+ }
405
+ ]
406
+ },
407
+ {
408
+ "name": "NousResearch/Hermes-3-Llama-3.1-8B",
409
+ "description": "Nous Research's latest Hermes 3 release in 8B size. Follows instruction closely.",
410
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/nous-logo.png",
411
+ "websiteUrl": "https://nousresearch.com/",
412
+ "modelUrl": "https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B",
413
+ "promptExamples": [
414
+ {
415
+ "title": "Write an email",
416
+ "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)"
417
+ },
418
+ {
419
+ "title": "Code a game",
420
+ "prompt": "Code a basic snake game in python, give explanations for each step."
421
+ },
422
+ {
423
+ "title": "Recipe help",
424
+ "prompt": "How do I make a delicious lemon cheesecake?"
425
+ }
426
+ ],
427
+ "parameters": {
428
+ "stop": ["<|im_end|>"],
429
+ "temperature": 0.6,
430
+ "truncate": 14336,
431
+ "max_new_tokens": 1536
432
+ }
433
+ },
434
+ {
435
+ "name": "internal/task",
436
+ "tokenizer" : "NousResearch/Hermes-3-Llama-3.1-8B",
437
+ "unlisted": true,
438
+ "tools" : true,
439
+ "endpoints": [
440
+ {
441
+ "type": "openai",
442
+ "baseURL": "https://internal.api-inference.huggingface.co/models/NousResearch/Hermes-3-Llama-3.1-8B/v1"
443
+ }
444
+ ],
445
+ "parameters": {
446
+ "temperature": 0.1,
447
+ "max_new_tokens": 256
448
+ },
449
+ }
450
+ ]
451
+
452
+ NODE_ENV: "prod"
453
+ NODE_LOG_STRUCTURED_DATA: true
454
+ OLD_MODELS: >
455
+ [
456
+ { "name": "bigcode/starcoder" },
457
+ { "name": "OpenAssistant/oasst-sft-6-llama-30b-xor" },
458
+ { "name": "HuggingFaceH4/zephyr-7b-alpha" },
459
+ { "name": "openchat/openchat_3.5" },
460
+ { "name": "openchat/openchat-3.5-1210" },
461
+ { "name": "tiiuae/falcon-180B-chat" },
462
+ { "name": "codellama/CodeLlama-34b-Instruct-hf" },
463
+ { "name": "google/gemma-7b-it" },
464
+ { "name": "meta-llama/Llama-2-70b-chat-hf" },
465
+ { "name": "codellama/CodeLlama-70b-Instruct-hf" },
466
+ { "name": "openchat/openchat-3.5-0106" },
467
+ { "name": "meta-llama/Meta-Llama-3-70B-Instruct" },
468
+ { "name": "meta-llama/Meta-Llama-3.1-405B-Instruct-FP8" },
469
+ {
470
+ "name": "CohereForAI/c4ai-command-r-plus",
471
+ "transferTo": "CohereForAI/c4ai-command-r-plus-08-2024"
472
+ },
473
+ {
474
+ "name": "01-ai/Yi-1.5-34B-Chat",
475
+ "transferTo": "CohereForAI/c4ai-command-r-plus-08-2024"
476
+ },
477
+ {
478
+ "name": "mistralai/Mixtral-8x7B-Instruct-v0.1",
479
+ "transferTo": "mistralai/Mistral-Small-3.1-24B-Instruct-2503"
480
+ },
481
+ {
482
+ "name": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
483
+ "transferTo": "NousResearch/Hermes-3-Llama-3.1-8B"
484
+ },
485
+ {
486
+ "name": "mistralai/Mistral-7B-Instruct-v0.3",
487
+ "transferTo": "mistralai/Mistral-Small-3.1-24B-Instruct-2503"
488
+ },
489
+ {
490
+ "name": "microsoft/Phi-3-mini-4k-instruct",
491
+ "transferTo": "microsoft/Phi-4"
492
+ },
493
+ {
494
+ "name": "meta-llama/Meta-Llama-3.1-70B-Instruct",
495
+ "transferTo": "meta-llama/Llama-3.3-70B-Instruct"
496
+ },
497
+ {
498
+ "name": "Qwen/QwQ-32B-Preview",
499
+ "transferTo": "Qwen/QwQ-32B"
500
+ },
501
+ {
502
+ "name": "mistralai/Mistral-Nemo-Instruct-2407",
503
+ "transferTo": "mistralai/Mistral-Small-3.1-24B-Instruct-2503"
504
+ },
505
+ {
506
+ "name": "microsoft/Phi-3.5-mini-instruct",
507
+ "transferTo": "microsoft/Phi-4"
508
+ },
509
+ {
510
+ "name": "Qwen/Qwen2.5-Coder-32B-Instruct",
511
+ "transferTo": "Qwen/QwQ-32B"
512
+ },
513
+ {
514
+ "name": "meta-llama/Llama-3.2-11B-Vision-Instruct",
515
+ "transferTo" : "Qwen/Qwen2.5-VL-32B-Instruct"
516
+ }
517
+ ]
518
+ PUBLIC_ORIGIN: "https://huggingface.co"
519
+ PUBLIC_SHARE_PREFIX: "https://hf.co/chat"
520
+ PUBLIC_ANNOUNCEMENT_BANNERS: >
521
+ [
522
+ {
523
+ "title": "Qwen 3 235B is available!",
524
+ "linkTitle": "Try it out!",
525
+ "linkHref": "https://huggingface.co/chat/models/Qwen/Qwen3-235B-A22B"
526
+ }
527
+ ]
528
+ PUBLIC_APP_NAME: "HuggingChat"
529
+ PUBLIC_APP_ASSETS: "huggingchat"
530
+ PUBLIC_APP_COLOR: "yellow"
531
+ PUBLIC_APP_DESCRIPTION: "Making the community's best AI chat models available to everyone."
532
+ PUBLIC_APP_DISCLAIMER_MESSAGE: "Disclaimer: AI is an area of active research with known problems such as biased generation and misinformation. Do not use this application for high-stakes decisions or advice."
533
+ PUBLIC_APP_GUEST_MESSAGE: "Sign in with a free Hugging Face account to continue using HuggingChat."
534
+ PUBLIC_APP_DATA_SHARING: 0
535
+ PUBLIC_APP_DISCLAIMER: 1
536
+ PUBLIC_PLAUSIBLE_SCRIPT_URL: "/js/script.js"
537
+ REQUIRE_FEATURED_ASSISTANTS: "true"
538
+ TASK_MODEL: "internal/task"
539
+ TEXT_EMBEDDING_MODELS: >
540
+ [{
541
+ "name": "bge-base-en-v1-5-sxa",
542
+ "displayName": "bge-base-en-v1-5-sxa",
543
+ "chunkCharLength": 512,
544
+ "endpoints": [{
545
+ "type": "tei",
546
+ "url": "https://huggingchat-tei.hf.space/"
547
+ }]
548
+ }]
549
+ WEBSEARCH_BLOCKLIST: '["youtube.com", "twitter.com"]'
550
+ XFF_DEPTH: '2'
551
+ TOOLS: >
552
+ [
553
+ {
554
+ "_id": "000000000000000000000001",
555
+ "displayName": "Image Generation",
556
+ "description": "Use this tool to generate images based on a prompt.",
557
+ "color": "yellow",
558
+ "icon": "camera",
559
+ "baseUrl": "black-forest-labs/FLUX.1-schnell",
560
+ "name": "image_generation",
561
+ "endpoint": "/infer",
562
+ "inputs": [
563
+ {
564
+ "name": "prompt",
565
+ "description": "A prompt to generate an image from",
566
+ "paramType": "required",
567
+ "type": "str"
568
+ },
569
+ { "name": "seed", "paramType": "fixed", "value": "0", "type": "float" },
570
+ {
571
+ "name": "randomize_seed",
572
+ "paramType": "fixed",
573
+ "value": "true",
574
+ "type": "bool"
575
+ },
576
+ {
577
+ "name": "width",
578
+ "description": "numeric value between 256 and 2048",
579
+ "paramType": "optional",
580
+ "default": 1024,
581
+ "type": "float"
582
+ },
583
+ {
584
+ "name": "height",
585
+ "description": "numeric value between 256 and 2048",
586
+ "paramType": "optional",
587
+ "default": 1024,
588
+ "type": "float"
589
+ },
590
+ {
591
+ "name": "num_inference_steps",
592
+ "paramType": "fixed",
593
+ "value": "4",
594
+ "type": "float"
595
+ }
596
+ ],
597
+ "outputComponent": "image",
598
+ "outputComponentIdx": 0,
599
+ "showOutput": true
600
+ },
601
+ {
602
+ "_id": "000000000000000000000002",
603
+ "displayName": "Document Parser",
604
+ "description": "Use this tool to parse any document and get its content in markdown format.",
605
+ "color": "yellow",
606
+ "icon": "cloud",
607
+ "baseUrl": "huggingchat/document-parser",
608
+ "name": "document_parser",
609
+ "endpoint": "/predict",
610
+ "inputs": [
611
+ {
612
+ "name": "document",
613
+ "description": "Filename of the document to parse",
614
+ "paramType": "required",
615
+ "type": "file",
616
+ "mimeTypes": 'application/*'
617
+ },
618
+ {
619
+ "name": "filename",
620
+ "paramType": "fixed",
621
+ "value": "document.pdf",
622
+ "type": "str"
623
+ }
624
+ ],
625
+ "outputComponent": "textbox",
626
+ "outputComponentIdx": 0,
627
+ "showOutput": false,
628
+ "isHidden": true
629
+ },
630
+ {
631
+ "_id": "000000000000000000000003",
632
+ "name": "edit_image",
633
+ "baseUrl": "multimodalart/cosxl",
634
+ "endpoint": "/run_edit",
635
+ "inputs": [
636
+ {
637
+ "name": "image",
638
+ "description": "The image path to be edited",
639
+ "paramType": "required",
640
+ "type": "file",
641
+ "mimeTypes": 'image/*'
642
+ },
643
+ {
644
+ "name": "prompt",
645
+ "description": "The prompt with which to edit the image",
646
+ "paramType": "required",
647
+ "type": "str"
648
+ },
649
+ {
650
+ "name": "negative_prompt",
651
+ "paramType": "fixed",
652
+ "value": "",
653
+ "type": "str"
654
+ },
655
+ {
656
+ "name": "guidance_scale",
657
+ "paramType": "fixed",
658
+ "value": 6.5,
659
+ "type": "float"
660
+ },
661
+ {
662
+ "name": "steps",
663
+ "paramType": "fixed",
664
+ "value": 30,
665
+ "type": "float"
666
+ }
667
+ ],
668
+ "outputComponent": "image",
669
+ "showOutput": true,
670
+ "displayName": "Image Editor",
671
+ "color": "green",
672
+ "icon": "camera",
673
+ "description": "This tool lets you edit images",
674
+ "outputComponentIdx": 0
675
+ }
676
+ ]
677
+ HF_ORG_ADMIN: '644171cfbd0c97265298aa99'
678
+ HF_ORG_EARLY_ACCESS: '5e67bd5b1009063689407478'
679
+ HF_API_ROOT: 'https://internal.api-inference.huggingface.co/models'
680
+ infisical:
681
+ enabled: true
682
+ env: "prod-us-east-1"
683
+
684
+ autoscaling:
685
+ enabled: true
686
+ minReplicas: 12
687
+ maxReplicas: 30
688
+ targetMemoryUtilizationPercentage: "50"
689
+ targetCPUUtilizationPercentage: "50"
690
+
691
+ resources:
692
+ requests:
693
+ cpu: 2
694
+ memory: 4Gi
695
+ limits:
696
+ cpu: 4
697
+ memory: 8Gi
698
+
699
+ monitoring:
700
+ enabled: true
chart/templates/_helpers.tpl ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- define "name" -}}
2
+ {{- default $.Release.Name | trunc 63 | trimSuffix "-" -}}
3
+ {{- end -}}
4
+
5
+ {{- define "app.name" -}}
6
+ chat-ui
7
+ {{- end -}}
8
+
9
+ {{- define "labels.standard" -}}
10
+ release: {{ $.Release.Name | quote }}
11
+ heritage: {{ $.Release.Service | quote }}
12
+ chart: "{{ include "name" . }}"
13
+ app: "{{ include "app.name" . }}"
14
+ {{- end -}}
15
+
16
+ {{- define "labels.resolver" -}}
17
+ release: {{ $.Release.Name | quote }}
18
+ heritage: {{ $.Release.Service | quote }}
19
+ chart: "{{ include "name" . }}"
20
+ app: "{{ include "app.name" . }}-resolver"
21
+ {{- end -}}
22
+
chart/templates/config.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v1
2
+ kind: ConfigMap
3
+ metadata:
4
+ labels: {{ include "labels.standard" . | nindent 4 }}
5
+ name: {{ include "name" . }}
6
+ namespace: {{ .Release.Namespace }}
7
+ data:
8
+ {{- range $key, $value := $.Values.envVars }}
9
+ {{ $key }}: {{ $value | quote }}
10
+ {{- end }}
chart/templates/deployment.yaml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ labels: {{ include "labels.standard" . | nindent 4 }}
5
+ name: {{ include "name" . }}
6
+ namespace: {{ .Release.Namespace }}
7
+ {{- if .Values.infisical.enabled }}
8
+ annotations:
9
+ secrets.infisical.com/auto-reload: "true"
10
+ {{- end }}
11
+ spec:
12
+ progressDeadlineSeconds: 600
13
+ {{- if not $.Values.autoscaling.enabled }}
14
+ replicas: {{ .Values.replicas }}
15
+ {{- end }}
16
+ revisionHistoryLimit: 10
17
+ selector:
18
+ matchLabels: {{ include "labels.standard" . | nindent 6 }}
19
+ strategy:
20
+ rollingUpdate:
21
+ maxSurge: 25%
22
+ maxUnavailable: 25%
23
+ type: RollingUpdate
24
+ template:
25
+ metadata:
26
+ labels: {{ include "labels.standard" . | nindent 8 }}
27
+ annotations:
28
+ checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
29
+ {{- if $.Values.envVars.NODE_LOG_STRUCTURED_DATA }}
30
+ co.elastic.logs/json.expand_keys: "true"
31
+ {{- end }}
32
+ spec:
33
+ {{- if .Values.serviceAccount.enabled }}
34
+ serviceAccountName: "{{ .Values.serviceAccount.name | default (include "name" .) }}"
35
+ {{- end }}
36
+ containers:
37
+ - name: chat-ui
38
+ image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}"
39
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
40
+ readinessProbe:
41
+ failureThreshold: 30
42
+ periodSeconds: 10
43
+ httpGet:
44
+ path: {{ $.Values.envVars.APP_BASE | default "" }}/healthcheck
45
+ port: {{ $.Values.envVars.APP_PORT | default 3000 | int }}
46
+ livenessProbe:
47
+ failureThreshold: 30
48
+ periodSeconds: 10
49
+ httpGet:
50
+ path: {{ $.Values.envVars.APP_BASE | default "" }}/healthcheck
51
+ port: {{ $.Values.envVars.APP_PORT | default 3000 | int }}
52
+ ports:
53
+ - containerPort: {{ $.Values.envVars.APP_PORT | default 3000 | int }}
54
+ name: http
55
+ protocol: TCP
56
+ {{- if $.Values.monitoring.enabled }}
57
+ - containerPort: {{ $.Values.envVars.METRICS_PORT | default 5565 | int }}
58
+ name: metrics
59
+ protocol: TCP
60
+ {{- end }}
61
+ resources: {{ toYaml .Values.resources | nindent 12 }}
62
+ {{- with $.Values.extraEnv }}
63
+ env:
64
+ {{- toYaml . | nindent 14 }}
65
+ {{- end }}
66
+ envFrom:
67
+ - configMapRef:
68
+ name: {{ include "name" . }}
69
+ {{- if $.Values.infisical.enabled }}
70
+ - secretRef:
71
+ name: {{ include "name" $ }}-secs
72
+ {{- end }}
73
+ {{- with $.Values.extraEnvFrom }}
74
+ {{- toYaml . | nindent 14 }}
75
+ {{- end }}
76
+ nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
77
+ tolerations: {{ toYaml .Values.tolerations | nindent 8 }}
78
+ volumes:
79
+ - name: config
80
+ configMap:
81
+ name: {{ include "name" . }}
chart/templates/hpa.yaml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if $.Values.autoscaling.enabled }}
2
+ apiVersion: autoscaling/v2
3
+ kind: HorizontalPodAutoscaler
4
+ metadata:
5
+ labels: {{ include "labels.standard" . | nindent 4 }}
6
+ name: {{ include "name" . }}
7
+ namespace: {{ .Release.Namespace }}
8
+ spec:
9
+ scaleTargetRef:
10
+ apiVersion: apps/v1
11
+ kind: Deployment
12
+ name: {{ include "name" . }}
13
+ minReplicas: {{ $.Values.autoscaling.minReplicas }}
14
+ maxReplicas: {{ $.Values.autoscaling.maxReplicas }}
15
+ metrics:
16
+ {{- if ne "" $.Values.autoscaling.targetMemoryUtilizationPercentage }}
17
+ - type: Resource
18
+ resource:
19
+ name: memory
20
+ target:
21
+ type: Utilization
22
+ averageUtilization: {{ $.Values.autoscaling.targetMemoryUtilizationPercentage | int }}
23
+ {{- end }}
24
+ {{- if ne "" $.Values.autoscaling.targetCPUUtilizationPercentage }}
25
+ - type: Resource
26
+ resource:
27
+ name: cpu
28
+ target:
29
+ type: Utilization
30
+ averageUtilization: {{ $.Values.autoscaling.targetCPUUtilizationPercentage | int }}
31
+ {{- end }}
32
+ behavior:
33
+ scaleDown:
34
+ stabilizationWindowSeconds: 600
35
+ policies:
36
+ - type: Percent
37
+ value: 10
38
+ periodSeconds: 60
39
+ scaleUp:
40
+ stabilizationWindowSeconds: 0
41
+ policies:
42
+ - type: Pods
43
+ value: 1
44
+ periodSeconds: 30
45
+ {{- end }}
chart/templates/infisical.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if .Values.infisical.enabled }}
2
+ apiVersion: secrets.infisical.com/v1alpha1
3
+ kind: InfisicalSecret
4
+ metadata:
5
+ name: {{ include "name" $ }}-infisical-secret
6
+ namespace: {{ $.Release.Namespace }}
7
+ spec:
8
+ authentication:
9
+ universalAuth:
10
+ credentialsRef:
11
+ secretName: {{ .Values.infisical.operatorSecretName | quote }}
12
+ secretNamespace: {{ .Values.infisical.operatorSecretNamespace | quote }}
13
+ secretsScope:
14
+ envSlug: {{ .Values.infisical.env | quote }}
15
+ projectSlug: {{ .Values.infisical.project | quote }}
16
+ secretsPath: /
17
+ hostAPI: {{ .Values.infisical.url | quote }}
18
+ managedSecretReference:
19
+ creationPolicy: Owner
20
+ secretName: {{ include "name" $ }}-secs
21
+ secretNamespace: {{ .Release.Namespace | quote }}
22
+ secretType: Opaque
23
+ resyncInterval: {{ .Values.infisical.resyncInterval }}
24
+ {{- end }}
chart/templates/ingress.yaml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if $.Values.ingress.enabled }}
2
+ apiVersion: networking.k8s.io/v1
3
+ kind: Ingress
4
+ metadata:
5
+ annotations: {{ toYaml .Values.ingress.annotations | nindent 4 }}
6
+ labels: {{ include "labels.standard" . | nindent 4 }}
7
+ name: {{ include "name" . }}
8
+ namespace: {{ .Release.Namespace }}
9
+ spec:
10
+ {{ if $.Values.ingress.className }}
11
+ ingressClassName: {{ .Values.ingress.className }}
12
+ {{ end }}
13
+ {{- with .Values.ingress.tls }}
14
+ tls:
15
+ - hosts:
16
+ - {{ $.Values.domain | quote }}
17
+ {{- with .secretName }}
18
+ secretName: {{ . }}
19
+ {{- end }}
20
+ {{- end }}
21
+ rules:
22
+ - host: {{ .Values.domain }}
23
+ http:
24
+ paths:
25
+ - backend:
26
+ service:
27
+ name: {{ include "name" . }}
28
+ port:
29
+ name: http
30
+ path: {{ $.Values.ingress.path | default "/" }}
31
+ pathType: Prefix
32
+ {{- end }}
chart/templates/network-policy.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if $.Values.networkPolicy.enabled }}
2
+ apiVersion: networking.k8s.io/v1
3
+ kind: NetworkPolicy
4
+ metadata:
5
+ name: {{ include "name" . }}
6
+ namespace: {{ .Release.Namespace }}
7
+ spec:
8
+ egress:
9
+ - ports:
10
+ - port: 53
11
+ protocol: UDP
12
+ to:
13
+ - namespaceSelector:
14
+ matchLabels:
15
+ kubernetes.io/metadata.name: kube-system
16
+ podSelector:
17
+ matchLabels:
18
+ k8s-app: kube-dns
19
+ - to:
20
+ {{- range $ip := .Values.networkPolicy.allowedBlocks }}
21
+ - ipBlock:
22
+ cidr: {{ $ip | quote }}
23
+ {{- end }}
24
+ - to:
25
+ - ipBlock:
26
+ cidr: 0.0.0.0/0
27
+ except:
28
+ - 10.0.0.0/8
29
+ - 172.16.0.0/12
30
+ - 192.168.0.0/16
31
+ - 169.254.169.254/32
32
+ podSelector:
33
+ matchLabels: {{ include "labels.standard" . | nindent 6 }}
34
+ policyTypes:
35
+ - Egress
36
+ {{- end }}
chart/templates/service-account.yaml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if and .Values.serviceAccount.enabled .Values.serviceAccount.create }}
2
+ apiVersion: v1
3
+ kind: ServiceAccount
4
+ automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
5
+ metadata:
6
+ name: "{{ .Values.serviceAccount.name | default (include "name" .) }}"
7
+ namespace: {{ .Release.Namespace }}
8
+ labels: {{ include "labels.standard" . | nindent 4 }}
9
+ {{- with .Values.serviceAccount.annotations }}
10
+ annotations:
11
+ {{- toYaml . | nindent 4 }}
12
+ {{- end }}
13
+ {{- end }}
chart/templates/service-monitor.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if $.Values.monitoring.enabled }}
2
+ apiVersion: monitoring.coreos.com/v1
3
+ kind: ServiceMonitor
4
+ metadata:
5
+ labels: {{ include "labels.standard" . | nindent 4 }}
6
+ name: {{ include "name" . }}
7
+ namespace: {{ .Release.Namespace }}
8
+ spec:
9
+ selector:
10
+ matchLabels: {{ include "labels.standard" . | nindent 6 }}
11
+ endpoints:
12
+ - port: metrics
13
+ path: /metrics
14
+ interval: 15s
15
+ {{- end }}
chart/templates/service.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: "{{ include "name" . }}"
5
+ annotations: {{ toYaml .Values.service.annotations | nindent 4 }}
6
+ namespace: {{ .Release.Namespace }}
7
+ labels: {{ include "labels.standard" . | nindent 4 }}
8
+ spec:
9
+ ports:
10
+ - name: http
11
+ port: 80
12
+ protocol: TCP
13
+ targetPort: http
14
+ {{- if $.Values.monitoring.enabled }}
15
+ - name: metrics
16
+ port: 5565
17
+ protocol: TCP
18
+ targetPort: metrics
19
+ {{- end }}
20
+ selector: {{ include "labels.standard" . | nindent 4 }}
21
+ type: {{.Values.service.type}}
chart/values.yaml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ image:
2
+ repository: ghcr.io/huggingface
3
+ name: chat-ui
4
+ tag: 0.0.0-latest
5
+ pullPolicy: IfNotPresent
6
+
7
+ replicas: 3
8
+
9
+ domain: huggingface.co
10
+
11
+ networkPolicy:
12
+ enabled: false
13
+ allowedBlocks: []
14
+
15
+ service:
16
+ type: NodePort
17
+ annotations: { }
18
+
19
+ serviceAccount:
20
+ enabled: false
21
+ create: false
22
+ name: ""
23
+ automountServiceAccountToken: true
24
+ annotations: { }
25
+
26
+ ingress:
27
+ enabled: true
28
+ path: "/"
29
+ annotations: { }
30
+ # className: "nginx"
31
+ tls: { }
32
+ # secretName: XXX
33
+
34
+ resources:
35
+ requests:
36
+ cpu: 2
37
+ memory: 4Gi
38
+ limits:
39
+ cpu: 2
40
+ memory: 4Gi
41
+ nodeSelector: {}
42
+ tolerations: []
43
+
44
+ envVars: { }
45
+
46
+ infisical:
47
+ enabled: false
48
+ env: ""
49
+ project: "huggingchat-v2-a1"
50
+ url: ""
51
+ resyncInterval: 60
52
+ operatorSecretName: "huggingchat-operator-secrets"
53
+ operatorSecretNamespace: "hub-utils"
54
+
55
+ # Allow to environment injections on top or instead of infisical
56
+ extraEnvFrom: []
57
+ extraEnv: []
58
+
59
+ autoscaling:
60
+ enabled: false
61
+ minReplicas: 1
62
+ maxReplicas: 2
63
+ targetMemoryUtilizationPercentage: ""
64
+ targetCPUUtilizationPercentage: ""
65
+
66
+ monitoring:
67
+ enabled: false
docs/source/_toctree.yml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - local: index
2
+ title: 🤗 Chat UI
3
+ - title: Installation
4
+ sections:
5
+ - local: installation/local
6
+ title: Local
7
+ - local: installation/spaces
8
+ title: Spaces
9
+ - local: installation/docker
10
+ title: Docker
11
+ - local: installation/helm
12
+ title: Helm
13
+ - title: Configuration
14
+ sections:
15
+ - local: configuration/overview
16
+ title: Overview
17
+ - local: configuration/theming
18
+ title: Theming
19
+ - local: configuration/open-id
20
+ title: OpenID
21
+ - local: configuration/web-search
22
+ title: Web Search
23
+ - local: configuration/metrics
24
+ title: Metrics
25
+ - local: configuration/embeddings
26
+ title: Text Embedding Models
27
+ - title: Models
28
+ sections:
29
+ - local: configuration/models/overview
30
+ title: Overview
31
+ - local: configuration/models/multimodal
32
+ title: Multimodal
33
+ - local: configuration/models/tools
34
+ title: Tools
35
+ - title: Providers
36
+ sections:
37
+ - local: configuration/models/providers/anthropic
38
+ title: Anthropic
39
+ - local: configuration/models/providers/aws
40
+ title: AWS
41
+ - local: configuration/models/providers/cloudflare
42
+ title: Cloudflare
43
+ - local: configuration/models/providers/cohere
44
+ title: Cohere
45
+ - local: configuration/models/providers/google
46
+ title: Google
47
+ - local: configuration/models/providers/langserve
48
+ title: Langserve
49
+ - local: configuration/models/providers/llamacpp
50
+ title: Llama.cpp
51
+ - local: configuration/models/providers/ollama
52
+ title: Ollama
53
+ - local: configuration/models/providers/openai
54
+ title: OpenAI
55
+ - local: configuration/models/providers/tgi
56
+ title: TGI
57
+ - local: configuration/common-issues
58
+ title: Common Issues
59
+ - title: Developing
60
+ sections:
61
+ - local: developing/architecture
62
+ title: Architecture
63
+ - local: developing/copy-huggingchat
64
+ title: Copy HuggingChat
docs/source/configuration/common-issues.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Common Issues
2
+
3
+ ## 403:You don't have access to this conversation
4
+
5
+ Most likely you are running chat-ui over HTTP. The recommended option is to setup something like NGINX to handle HTTPS and proxy the requests to chat-ui. If you really need to run over HTTP you can add `ALLOW_INSECURE_COOKIES=true` to your `.env.local`.
6
+
7
+ Make sure to set your `PUBLIC_ORIGIN` in your `.env.local` to the correct URL as well.
docs/source/configuration/embeddings.md ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Text Embedding Models
2
+
3
+ By default (for backward compatibility), when `TEXT_EMBEDDING_MODELS` environment variable is not defined, [transformers.js](https://huggingface.co/docs/transformers.js) embedding models will be used for embedding tasks, specifically, the [Xenova/gte-small](https://huggingface.co/Xenova/gte-small) model.
4
+
5
+ You can customize the embedding model by setting `TEXT_EMBEDDING_MODELS` in your `.env.local` file where the required fields are `name`, `chunkCharLength` and `endpoints`.
6
+
7
+ Supported text embedding backends are: [`transformers.js`](https://huggingface.co/docs/transformers.js), [`TEI`](https://github.com/huggingface/text-embeddings-inference) and [`OpenAI`](https://platform.openai.com/docs/guides/embeddings). `transformers.js` models run locally as part of `chat-ui`, whereas `TEI` models run in a different environment & accessed through an API endpoint. `openai` models are accessed through the [OpenAI API](https://platform.openai.com/docs/guides/embeddings).
8
+
9
+ When more than one embedding models are supplied in `.env.local` file, the first will be used by default, and the others will only be used on LLM's which configured `embeddingModel` to the name of the model.
10
+
11
+ ## Transformers.js
12
+
13
+ The Transformers.js backend uses local CPU for the embedding which can be quite slow. If possible, consider using TEI or OpenAI embeddings instead if you use web search frequently, as performance will improve significantly.
14
+
15
+ ```ini
16
+ TEXT_EMBEDDING_MODELS = `[
17
+ {
18
+ "name": "Xenova/gte-small",
19
+ "displayName": "Xenova/gte-small",
20
+ "description": "locally running embedding",
21
+ "chunkCharLength": 512,
22
+ "endpoints": [
23
+ { "type": "transformersjs" }
24
+ ]
25
+ }
26
+ ]`
27
+ ```
28
+
29
+ ## Text Embeddings Inference (TEI)
30
+
31
+ > Text Embeddings Inference (TEI) is a comprehensive toolkit designed for efficient deployment and serving of open source text embeddings models. It enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE, and E5.
32
+
33
+ Some recommended models at the time of writing (May 2024) are `Snowflake/snowflake-arctic-embed-m` and `BAAI/bge-large-en-v1.5`. You may run TEI locally with GPU support via Docker:
34
+
35
+ `docker run --gpus all -p 8080:80 -v tei-data:/data --name tei ghcr.io/huggingface/text-embeddings-inference:1.2 --model-id YOUR/HF_MODEL`
36
+
37
+ You can then hook this up to your Chat UI instance with the following configuration.
38
+
39
+ ```ini
40
+ TEXT_EMBEDDING_MODELS=`[
41
+ {
42
+ "name": "YOUR/HF_MODEL",
43
+ "displayName": "YOUR/HF_MODEL",
44
+ "preQuery": "Check the model documentation for the preQuery. Not all models have one",
45
+ "prePassage": "Check the model documentation for the prePassage. Not all models have one",
46
+ "chunkCharLength": 512,
47
+ "endpoints": [{
48
+ "type": "tei",
49
+ "url": "http://127.0.0.1:8080/"
50
+ }]
51
+ }
52
+ ]`
53
+ ```
54
+
55
+ Examples for `Snowflake/snowflake-arctic-embed-m` and `BAAI/bge-large-en-v1.5`:
56
+
57
+ ```ini
58
+ TEXT_EMBEDDING_MODELS=`[
59
+ {
60
+ "name": "Snowflake/snowflake-arctic-embed-m",
61
+ "displayName": "Snowflake/snowflake-arctic-embed-m",
62
+ "preQuery": "Represent this sentence for searching relevant passages: ",
63
+ "chunkCharLength": 512,
64
+ "endpoints": [{
65
+ "type": "tei",
66
+ "url": "http://127.0.0.1:8080/"
67
+ }]
68
+ },{
69
+ "name": "BAAI/bge-large-en-v1.5",
70
+ "displayName": "BAAI/bge-large-en-v1.5",
71
+ "chunkCharLength": 512,
72
+ "endpoints": [{
73
+ "type": "tei",
74
+ "url": "http://127.0.0.1:8080/"
75
+ }]
76
+ }
77
+ ]`
78
+ ```
79
+
80
+ ## OpenAI
81
+
82
+ It's also possible to host your own OpenAI API compatible embedding models. [`Infinity`](https://github.com/michaelfeil/infinity) is one example. You may run it locally with Docker:
83
+
84
+ `docker run -it --gpus all -v infinity-data:/app/.cache -p 7997:7997 michaelf34/infinity:latest v2 --model-id nomic-ai/nomic-embed-text-v1 --port 7997`
85
+
86
+ You can then hook this up to your Chat UI instance with the following configuration.
87
+
88
+ ```ini
89
+ TEXT_EMBEDDING_MODELS=`[
90
+ {
91
+ "name": "nomic-ai/nomic-embed-text-v1",
92
+ "displayName": "nomic-ai/nomic-embed-text-v1",
93
+ "chunkCharLength": 512,
94
+ "model": {
95
+ "name": "nomic-ai/nomic-embed-text-v1"
96
+ },
97
+ "endpoints": [
98
+ {
99
+ "type": "openai",
100
+ "url": "https://127.0.0.1:7997/embeddings"
101
+ }
102
+ ]
103
+ }
104
+ ]`
105
+ ```
docs/source/configuration/metrics.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Metrics
2
+
3
+ The server can expose prometheus metrics on port `5565` but is off by default. You may enable the metrics server with `METRICS_ENABLED=true` and change the port with `METRICS_PORT=1234`.
4
+
5
+ <Tip>
6
+
7
+ In development with `npm run dev`, the metrics server does not shutdown gracefully due to Sveltekit not providing hooks for restart. It's recommended to disable the metrics server in this case.
8
+
9
+ </Tip>
docs/source/configuration/models/multimodal.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multimodal
2
+
3
+ We currently support [IDEFICS](https://huggingface.co/blog/idefics) (hosted on [TGI](./providers/tgi)), OpenAI and Anthropic Claude 3 as multimodal models. You can enable it by setting `multimodal: true` in your `MODELS` configuration. For IDEFICS, you must have a [PRO HF Api token](https://huggingface.co/settings/tokens). For OpenAI, see the [OpenAI section](./providers/openai). For Anthropic, see the [Anthropic section](./providers/anthropic).
4
+
5
+ ```ini
6
+ MODELS=`[
7
+ {
8
+ "name": "HuggingFaceM4/idefics-80b-instruct",
9
+ "multimodal" : true,
10
+ "description": "IDEFICS is the new multimodal model by Hugging Face.",
11
+ "preprompt": "",
12
+ "chatPromptTemplate" : "{{#each messages}}{{#ifUser}}User: {{content}}{{/ifUser}}<end_of_utterance>\nAssistant: {{#ifAssistant}}{{content}}\n{{/ifAssistant}}{{/each}}",
13
+ "parameters": {
14
+ "temperature": 0.1,
15
+ "top_p": 0.95,
16
+ "repetition_penalty": 1.2,
17
+ "top_k": 12,
18
+ "truncate": 1000,
19
+ "max_new_tokens": 1024,
20
+ "stop": ["<end_of_utterance>", "User:", "\nUser:"]
21
+ }
22
+ }
23
+ ]`
24
+ ```
docs/source/configuration/models/overview.md ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Models Overview
2
+
3
+ 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 :
4
+
5
+ ```ini
6
+ MODELS=`[
7
+ {
8
+ "name": "mistralai/Mistral-7B-Instruct-v0.2",
9
+ "displayName": "mistralai/Mistral-7B-Instruct-v0.2",
10
+ "description": "Mistral 7B is a new Apache 2.0 model, released by Mistral AI that outperforms Llama2 13B in benchmarks.",
11
+ "websiteUrl": "https://mistral.ai/news/announcing-mistral-7b/",
12
+ "preprompt": "",
13
+ "chatPromptTemplate" : "<s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{#if @root.preprompt}}{{@root.preprompt}}\n{{/if}}{{/if}}{{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s>{{/ifAssistant}}{{/each}}",
14
+ "parameters": {
15
+ "temperature": 0.3,
16
+ "top_p": 0.95,
17
+ "repetition_penalty": 1.2,
18
+ "top_k": 50,
19
+ "truncate": 3072,
20
+ "max_new_tokens": 1024,
21
+ "stop": ["</s>"]
22
+ },
23
+ "promptExamples": [
24
+ {
25
+ "title": "Write an email",
26
+ "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)"
27
+ }, {
28
+ "title": "Code a game",
29
+ "prompt": "Code a basic snake game in python, give explanations for each step."
30
+ }, {
31
+ "title": "Recipe help",
32
+ "prompt": "How do I make a delicious lemon cheesecake?"
33
+ }
34
+ ]
35
+ }
36
+ ]`
37
+
38
+ ```
39
+
40
+ 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.
41
+
42
+ ## Chat Prompt Template
43
+
44
+ When querying the model for a chat response, the `chatPromptTemplate` template is used. `messages` is an array of chat messages, it has the format `[{ content: string }, ...]`. To identify if a message is a user message or an assistant message the `ifUser` and `ifAssistant` block helpers can be used.
45
+
46
+ The following is the default `chatPromptTemplate`, although newlines and indentiation have been added for readability. You can find the prompts used in production for HuggingChat [here](https://github.com/huggingface/chat-ui/blob/main/PROMPTS.md). The templating language used is [Handlebars](https://www.npmjs.com/package/handlebars).
47
+
48
+ ```handlebars
49
+ {{preprompt}}
50
+ {{#each messages}}
51
+ {{#ifUser}}{{@root.userMessageToken}}{{content}}{{@root.userMessageEndToken}}{{/ifUser}}
52
+ {{#ifAssistant
53
+ }}{{@root.assistantMessageToken}}{{content}}{{@root.assistantMessageEndToken}}{{/ifAssistant}}
54
+ {{/each}}
55
+ {{assistantMessageToken}}
56
+ ```
57
+
58
+ ## Custom endpoint authorization
59
+
60
+ ### Basic and Bearer
61
+
62
+ Custom endpoints may require authorization, depending on how you configure them. Authentication will usually be set either with `Basic` or `Bearer`.
63
+
64
+ For `Basic` we will need to generate a base64 encoding of the username and password.
65
+
66
+ `echo -n "USER:PASS" | base64`
67
+
68
+ > VVNFUjpQQVNT
69
+
70
+ For `Bearer` you can use a token, which can be grabbed from [here](https://huggingface.co/settings/tokens).
71
+
72
+ You can then add the generated information and the `authorization` parameter to your `.env.local`.
73
+
74
+ ```ini
75
+ "endpoints": [
76
+ {
77
+ "url": "https://HOST:PORT",
78
+ "authorization": "Basic VVNFUjpQQVNT",
79
+ }
80
+ ]
81
+ ```
82
+
83
+ Please note that if `HF_TOKEN` is also set or not empty, it will take precedence.
84
+
85
+ ## Models hosted on multiple custom endpoints
86
+
87
+ If the model being hosted will be available on multiple servers/instances add the `weight` parameter to your `.env.local`. The `weight` will be used to determine the probability of requesting a particular endpoint.
88
+
89
+ ```ini
90
+ "endpoints": [
91
+ {
92
+ "url": "https://HOST:PORT",
93
+ "weight": 1
94
+ },
95
+ {
96
+ "url": "https://HOST:PORT",
97
+ "weight": 2
98
+ }
99
+ ...
100
+ ]
101
+ ```
102
+
103
+ ## Client Certificate Authentication (mTLS)
104
+
105
+ Custom endpoints may require client certificate authentication, depending on how you configure them. To enable mTLS between Chat UI and your custom endpoint, you will need to set the `USE_CLIENT_CERTIFICATE` to `true`, and add the `CERT_PATH` and `KEY_PATH` parameters to your `.env.local`. These parameters should point to the location of the certificate and key files on your local machine. The certificate and key files should be in PEM format. The key file can be encrypted with a passphrase, in which case you will also need to add the `CLIENT_KEY_PASSWORD` parameter to your `.env.local`.
106
+
107
+ If you're using a certificate signed by a private CA, you will also need to add the `CA_PATH` parameter to your `.env.local`. This parameter should point to the location of the CA certificate file on your local machine.
108
+
109
+ If you're using a self-signed certificate, e.g. for testing or development purposes, you can set the `REJECT_UNAUTHORIZED` parameter to `false` in your `.env.local`. This will disable certificate validation, and allow Chat UI to connect to your custom endpoint.
110
+
111
+ ## Specific Embedding Model
112
+
113
+ A model can use any of the embedding models defined under `TEXT_EMBEDDING_MODELS`, (currently used when web searching). By default it will use the first embedding model, but it can be changed with the field `embeddingModel`:
114
+
115
+ ```ini
116
+ TEXT_EMBEDDING_MODELS = `[
117
+ {
118
+ "name": "Xenova/gte-small",
119
+ "chunkCharLength": 512,
120
+ "endpoints": [
121
+ {"type": "transformersjs"}
122
+ ]
123
+ },
124
+ {
125
+ "name": "intfloat/e5-base-v2",
126
+ "chunkCharLength": 768,
127
+ "endpoints": [
128
+ {"type": "tei", "url": "http://127.0.0.1:8080/", "authorization": "Basic VVNFUjpQQVNT"},
129
+ {"type": "tei", "url": "http://127.0.0.1:8081/"}
130
+ ]
131
+ }
132
+ ]`
133
+
134
+ MODELS=`[
135
+ {
136
+ "name": "Ollama Mistral",
137
+ "chatPromptTemplate": "...",
138
+ "embeddingModel": "intfloat/e5-base-v2"
139
+ "parameters": {
140
+ ...
141
+ },
142
+ "endpoints": [
143
+ ...
144
+ ]
145
+ }
146
+ ]`
147
+ ```
docs/source/configuration/models/providers/anthropic.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Anthropic
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | Yes |
7
+
8
+ We also support Anthropic models (including multimodal ones via `multmodal: true`) through the official SDK. You may provide your API key via the `ANTHROPIC_API_KEY` env variable, or alternatively, through the `endpoints.apiKey` as per the following example.
9
+
10
+ ```ini
11
+ MODELS=`[
12
+ {
13
+ "name": "claude-3-haiku-20240307",
14
+ "displayName": "Claude 3 Haiku",
15
+ "description": "Fastest and most compact model for near-instant responsiveness",
16
+ "multimodal": true,
17
+ "parameters": {
18
+ "max_new_tokens": 4096,
19
+ },
20
+ "endpoints": [
21
+ {
22
+ "type": "anthropic",
23
+ // optionals
24
+ "apiKey": "sk-ant-...",
25
+ "baseURL": "https://api.anthropic.com",
26
+ "defaultHeaders": {},
27
+ "defaultQuery": {}
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ "name": "claude-3-sonnet-20240229",
33
+ "displayName": "Claude 3 Sonnet",
34
+ "description": "Ideal balance of intelligence and speed",
35
+ "multimodal": true,
36
+ "parameters": {
37
+ "max_new_tokens": 4096,
38
+ },
39
+ "endpoints": [
40
+ {
41
+ "type": "anthropic",
42
+ // optionals
43
+ "apiKey": "sk-ant-...",
44
+ "baseURL": "https://api.anthropic.com",
45
+ "defaultHeaders": {},
46
+ "defaultQuery": {}
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ "name": "claude-3-opus-20240229",
52
+ "displayName": "Claude 3 Opus",
53
+ "description": "Most powerful model for highly complex tasks",
54
+ "multimodal": true,
55
+ "parameters": {
56
+ "max_new_tokens": 4096
57
+ },
58
+ "endpoints": [
59
+ {
60
+ "type": "anthropic",
61
+ // optionals
62
+ "apiKey": "sk-ant-...",
63
+ "baseURL": "https://api.anthropic.com",
64
+ "defaultHeaders": {},
65
+ "defaultQuery": {}
66
+ }
67
+ ]
68
+ }
69
+ ]`
70
+ ```
71
+
72
+ ## VertexAI
73
+
74
+ We also support using Anthropic models running on Vertex AI. Authentication is done using Google Application Default Credentials. Project ID can be provided through the `endpoints.projectId` as per the following example:
75
+
76
+ ```ini
77
+ MODELS=`[
78
+ {
79
+ "name": "claude-3-haiku@20240307",
80
+ "displayName": "Claude 3 Haiku",
81
+ "description": "Fastest, most compact model for near-instant responsiveness",
82
+ "multimodal": true,
83
+ "parameters": {
84
+ "max_new_tokens": 4096
85
+ },
86
+ "endpoints": [
87
+ {
88
+ "type": "anthropic-vertex",
89
+ "region": "us-central1",
90
+ "projectId": "gcp-project-id",
91
+ // optionals
92
+ "defaultHeaders": {},
93
+ "defaultQuery": {}
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ "name": "claude-3-sonnet@20240229",
99
+ "displayName": "Claude 3 Sonnet",
100
+ "description": "Ideal balance of intelligence and speed",
101
+ "multimodal": true,
102
+ "parameters": {
103
+ "max_new_tokens": 4096,
104
+ },
105
+ "endpoints": [
106
+ {
107
+ "type": "anthropic-vertex",
108
+ "region": "us-central1",
109
+ "projectId": "gcp-project-id",
110
+ // optionals
111
+ "defaultHeaders": {},
112
+ "defaultQuery": {}
113
+ }
114
+ ]
115
+ },
116
+ ]`
117
+ ```
docs/source/configuration/models/providers/aws.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Amazon Web Services (AWS)
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | No |
7
+
8
+ You may specify your Amazon SageMaker instance as an endpoint for Chat UI:
9
+
10
+ ```ini
11
+ MODELS=`[{
12
+ "name": "your-model",
13
+ "displayName": "Your Model",
14
+ "description": "Your description",
15
+ "parameters": {
16
+ "max_new_tokens": 4096
17
+ },
18
+ "endpoints": [
19
+ {
20
+ "type" : "aws",
21
+ "service" : "sagemaker"
22
+ "url": "",
23
+ "accessKey": "",
24
+ "secretKey" : "",
25
+ "sessionToken": "",
26
+ "region": "",
27
+ "weight": 1
28
+ }
29
+ ]
30
+ }]`
31
+ ```
32
+
33
+ You can also set `"service": "lambda"` to use a lambda instance.
34
+
35
+ You can get the `accessKey` and `secretKey` from your AWS user, under programmatic access.
docs/source/configuration/models/providers/cloudflare.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Cloudflare
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | No |
7
+
8
+ You may use Cloudflare Workers AI to run your own models with serverless inference.
9
+
10
+ You will need to have a Cloudflare account, then get your [account ID](https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/) as well as your [API token](https://developers.cloudflare.com/workers-ai/get-started/rest-api/#1-get-an-api-token) for Workers AI.
11
+
12
+ You can either specify them directly in your `.env.local` using the `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` variables, or you can set them directly in the endpoint config.
13
+
14
+ You can find the list of models available on Cloudflare [here](https://developers.cloudflare.com/workers-ai/models/#text-generation).
15
+
16
+ ```ini
17
+ MODELS=`[
18
+ {
19
+ "name" : "nousresearch/hermes-2-pro-mistral-7b",
20
+ "tokenizer": "nousresearch/hermes-2-pro-mistral-7b",
21
+ "parameters": {
22
+ "stop": ["<|im_end|>"]
23
+ },
24
+ "endpoints" : [
25
+ {
26
+ "type" : "cloudflare"
27
+ <!-- optionally specify these
28
+ "accountId": "your-account-id",
29
+ "authToken": "your-api-token"
30
+ -->
31
+ }
32
+ ]
33
+ }
34
+ ]`
35
+ ```
docs/source/configuration/models/providers/cohere.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Cohere
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | Yes |
6
+ | [Multimodal](../multimodal) | No |
7
+
8
+ You may use Cohere to run their models directly from Chat UI. You will need to have a Cohere account, then get your [API token](https://dashboard.cohere.com/api-keys). You can either specify it directly in your `.env.local` using the `COHERE_API_TOKEN` variable, or you can set it in the endpoint config.
9
+
10
+ Here is an example of a Cohere model config. You can set which model you want to use by setting the `id` field to the model name.
11
+
12
+ ```ini
13
+ MODELS=`[
14
+ {
15
+ "name": "command-r-plus",
16
+ "displayName": "Command R+",
17
+ "tools": true,
18
+ "endpoints": [{
19
+ "type": "cohere",
20
+ <!-- optionally specify these, or use COHERE_API_TOKEN
21
+ "apiKey": "your-api-token"
22
+ -->
23
+ }]
24
+ }
25
+ ]`
26
+ ```
docs/source/configuration/models/providers/google.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Google
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | No |
7
+
8
+ Chat UI can connect to the google Vertex API endpoints ([List of supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models)).
9
+
10
+ To enable:
11
+
12
+ 1. [Select](https://console.cloud.google.com/project) or [create](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project) a Google Cloud project.
13
+ 1. [Enable billing for your project](https://cloud.google.com/billing/docs/how-to/modify-project).
14
+ 1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com).
15
+ 1. [Set up authentication with a service account](https://cloud.google.com/docs/authentication/getting-started)
16
+ so you can access the API from your local workstation.
17
+
18
+ The service account credentials file can be imported as an environmental variable:
19
+
20
+ ```ini
21
+ GOOGLE_APPLICATION_CREDENTIALS = clientid.json
22
+ ```
23
+
24
+ Make sure your docker container has access to the file and the variable is correctly set.
25
+ Afterwards Google Vertex endpoints can be configured as following:
26
+
27
+ ```ini
28
+ MODELS=`[
29
+ {
30
+ "name": "gemini-1.5-pro",
31
+ "displayName": "Vertex Gemini Pro 1.5",
32
+ "endpoints" : [{
33
+ "type": "vertex",
34
+ "project": "abc-xyz",
35
+ "location": "europe-west3",
36
+ "extraBody": {
37
+ "model_version": "gemini-1.5-pro-002",
38
+ },
39
+ // Optional
40
+ "safetyThreshold": "BLOCK_MEDIUM_AND_ABOVE",
41
+ "apiEndpoint": "", // alternative api endpoint url,
42
+ "tools": [{
43
+ "googleSearchRetrieval": {
44
+ "disableAttribution": true
45
+ }
46
+ }]
47
+ }]
48
+ }
49
+ ]`
50
+ ```
51
+
52
+ ## GenAI
53
+
54
+ Or use the Gemini API API provider [from](https://github.com/google-gemini/generative-ai-js#readme):
55
+
56
+ Make sure that you have an API key from Google Cloud Platform. To get an API key, follow the instructions [here](https://ai.google.dev/gemini-api/docs/api-key).
57
+
58
+ You can either specify them directly in your `.env.local` using the `GOOGLE_GENAI_API_KEY` variables, or you can set them directly in the endpoint config.
59
+
60
+ You can find the list of models available [here](https://ai.google.dev/gemini-api/docs/models/gemini), and experimental models available [here](https://ai.google.dev/gemini-api/docs/models/experimental-models).
61
+
62
+ ```ini
63
+ MODELS=`[
64
+ {
65
+ "name": "gemini-1.5-flash",
66
+ "displayName": "Gemini Flash 1.5",
67
+ "multimodal": true,
68
+ "endpoints": [
69
+ {
70
+ "type": "genai",
71
+
72
+ // Optional
73
+ "apiKey": "abc...xyz"
74
+ "safetyThreshold": "BLOCK_MEDIUM_AND_ABOVE",
75
+ }
76
+ ]
77
+ },
78
+ {
79
+ "name": "gemini-1.5-pro",
80
+ "displayName": "Gemini Pro 1.5",
81
+ "multimodal": false,
82
+ "endpoints": [
83
+ {
84
+ "type": "genai",
85
+
86
+ // Optional
87
+ "apiKey": "abc...xyz"
88
+ }
89
+ ]
90
+ }
91
+ ]`
92
+ ```
docs/source/configuration/models/providers/langserve.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LangServe
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | No |
7
+
8
+ LangChain applications that are deployed using LangServe can be called with the following config:
9
+
10
+ ```ini
11
+ MODELS=`[
12
+ {
13
+ "name": "summarization-chain",
14
+ "displayName": "Summarization Chain"
15
+ "endpoints" : [{
16
+ "type": "langserve",
17
+ "url" : "http://127.0.0.1:8100",
18
+ }]
19
+ }
20
+ ]`
21
+
22
+ ```
docs/source/configuration/models/providers/llamacpp.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Llama.cpp
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | No |
7
+
8
+ Chat UI supports the llama.cpp API server directly without the need for an adapter. You can do this using the `llamacpp` endpoint type.
9
+
10
+ If you want to run Chat UI with llama.cpp, you can do the following, using [microsoft/Phi-3-mini-4k-instruct-gguf](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf) as an example model:
11
+
12
+ ```bash
13
+ # install llama.cpp
14
+ brew install llama.cpp
15
+ # start llama.cpp server
16
+ llama-server --hf-repo microsoft/Phi-3-mini-4k-instruct-gguf --hf-file Phi-3-mini-4k-instruct-q4.gguf -c 4096
17
+ ```
18
+
19
+ _note: you can swap the `hf-repo` and `hf-file` with your fav GGUF on the [Hub](https://huggingface.co/models?library=gguf). For example: `--hf-repo TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF` for [this repo](https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF) & `--hf-file tinyllama-1.1b-chat-v1.0.Q4_0.gguf` for [this file](https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/blob/main/tinyllama-1.1b-chat-v1.0.Q4_0.gguf)._
20
+
21
+ A local LLaMA.cpp HTTP Server will start on `http://localhost:8080` (to change the port or any other default options, please find [LLaMA.cpp HTTP Server readme](https://github.com/ggerganov/llama.cpp/tree/master/examples/server)).
22
+
23
+ Add the following to your `.env.local`:
24
+
25
+ ```ini
26
+ MODELS=`[
27
+ {
28
+ "name": "Local microsoft/Phi-3-mini-4k-instruct-gguf",
29
+ "tokenizer": "microsoft/Phi-3-mini-4k-instruct-gguf",
30
+ "preprompt": "",
31
+ "chatPromptTemplate": "<s>{{preprompt}}{{#each messages}}{{#ifUser}}<|user|>\n{{content}}<|end|>\n<|assistant|>\n{{/ifUser}}{{#ifAssistant}}{{content}}<|end|>\n{{/ifAssistant}}{{/each}}",
32
+ "parameters": {
33
+ "stop": ["<|end|>", "<|endoftext|>", "<|assistant|>"],
34
+ "temperature": 0.7,
35
+ "max_new_tokens": 1024,
36
+ "truncate": 3071
37
+ },
38
+ "endpoints": [{
39
+ "type" : "llamacpp",
40
+ "baseURL": "http://localhost:8080"
41
+ }],
42
+ },
43
+ ]`
44
+ ```
45
+
46
+ <div class="flex justify-center">
47
+ <img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/llamacpp-light.png" height="auto"/>
48
+ <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/llamacpp-dark.png" height="auto"/>
49
+ </div>
docs/source/configuration/models/providers/ollama.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ollama
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | No |
7
+
8
+ We also support the Ollama inference server. Spin up a model with
9
+
10
+ ```bash
11
+ ollama run mistral
12
+ ```
13
+
14
+ Then specify the endpoints like so:
15
+
16
+ ```ini
17
+ MODELS=`[
18
+ {
19
+ "name": "Ollama Mistral",
20
+ "chatPromptTemplate": "<s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{#if @root.preprompt}}{{@root.preprompt}}\n{{/if}}{{/if}} {{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s> {{/ifAssistant}}{{/each}}",
21
+ "parameters": {
22
+ "temperature": 0.1,
23
+ "top_p": 0.95,
24
+ "repetition_penalty": 1.2,
25
+ "top_k": 50,
26
+ "truncate": 3072,
27
+ "max_new_tokens": 1024,
28
+ "stop": ["</s>"]
29
+ },
30
+ "endpoints": [
31
+ {
32
+ "type": "ollama",
33
+ "url" : "http://127.0.0.1:11434",
34
+ "ollamaName" : "mistral"
35
+ }
36
+ ]
37
+ }
38
+ ]`
39
+ ```
docs/source/configuration/models/providers/openai.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenAI
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | Yes |
7
+
8
+ Chat UI can be used with any API server that supports OpenAI API compatibility, for example [text-generation-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai), [LocalAI](https://github.com/go-skynet/LocalAI), [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md), [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), and [ialacol](https://github.com/chenhunghan/ialacol) and [vllm](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html).
9
+
10
+ The following example config makes Chat UI works with [text-generation-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai), the `endpoint.baseUrl` is the url of the OpenAI API compatible server, this overrides the baseUrl to be used by OpenAI instance. The `endpoint.completion` determine which endpoint to be used, default is `chat_completions` which uses `/chat/completions`, change to `endpoint.completion` to `completions` to use the `/completions` endpoint.
11
+
12
+ ```ini
13
+ MODELS=`[
14
+ {
15
+ "name": "text-generation-webui",
16
+ "id": "text-generation-webui",
17
+ "parameters": {
18
+ "temperature": 0.9,
19
+ "top_p": 0.95,
20
+ "repetition_penalty": 1.2,
21
+ "top_k": 50,
22
+ "truncate": 1000,
23
+ "max_new_tokens": 1024,
24
+ "stop": []
25
+ },
26
+ "endpoints": [{
27
+ "type" : "openai",
28
+ "baseURL": "http://localhost:8000/v1"
29
+ }]
30
+ }
31
+ ]`
32
+
33
+ ```
34
+
35
+ The `openai` type includes official OpenAI models. You can add, for example, GPT4/GPT3.5 as a "openai" model:
36
+
37
+ ```ini
38
+ OPENAI_API_KEY=#your openai api key here
39
+ MODELS=`[{
40
+ "name": "gpt-4",
41
+ "displayName": "GPT 4",
42
+ "endpoints" : [{
43
+ "type": "openai",
44
+ "apiKey": "or your openai api key here"
45
+ }]
46
+ },{
47
+ "name": "gpt-3.5-turbo",
48
+ "displayName": "GPT 3.5 Turbo",
49
+ "endpoints" : [{
50
+ "type": "openai",
51
+ "apiKey": "or your openai api key here"
52
+ }]
53
+ }]`
54
+ ```
55
+
56
+ We also support models in the `o1` family. You need to add a few more options ot the config: Here is an example for `o1-mini`:
57
+
58
+ ```ini
59
+ MODELS=`[
60
+ {
61
+ "name": "o1-mini",
62
+ "description": "ChatGPT o1-mini",
63
+ "systemRoleSupported": false,
64
+ "parameters": {
65
+ "max_new_tokens": 2048,
66
+ },
67
+ "endpoints" : [{
68
+ "type": "openai",
69
+ "useCompletionTokens": true,
70
+ }]
71
+ }
72
+ ]
73
+ ```
74
+
75
+ You may also consume any model provider that provides compatible OpenAI API endpoint. For example, you may self-host [Portkey](https://github.com/Portkey-AI/gateway) gateway and experiment with Claude or GPTs offered by Azure OpenAI. Example for Claude from Anthropic:
76
+
77
+ ```ini
78
+ MODELS=`[{
79
+ "name": "claude-2.1",
80
+ "displayName": "Claude 2.1",
81
+ "description": "Anthropic has been founded by former OpenAI researchers...",
82
+ "parameters": {
83
+ "temperature": 0.5,
84
+ "max_new_tokens": 4096,
85
+ },
86
+ "endpoints": [
87
+ {
88
+ "type": "openai",
89
+ "baseURL": "https://gateway.example.com/v1",
90
+ "defaultHeaders": {
91
+ "x-portkey-config": '{"provider":"anthropic","api_key":"sk-ant-abc...xyz"}'
92
+ }
93
+ }
94
+ ]
95
+ }]`
96
+ ```
97
+
98
+ Example for GPT 4 deployed on Azure OpenAI:
99
+
100
+ ```ini
101
+ MODELS=`[{
102
+ "id": "gpt-4-1106-preview",
103
+ "name": "gpt-4-1106-preview",
104
+ "displayName": "gpt-4-1106-preview",
105
+ "parameters": {
106
+ "temperature": 0.5,
107
+ "max_new_tokens": 4096,
108
+ },
109
+ "endpoints": [
110
+ {
111
+ "type": "openai",
112
+ "baseURL": "https://{resource-name}.openai.azure.com/openai/deployments/{deployment-id}",
113
+ "defaultHeaders": {
114
+ "api-key": "{api-key}"
115
+ },
116
+ "defaultQuery": {
117
+ "api-version": "2023-05-15"
118
+ }
119
+ }
120
+ ]
121
+ }]`
122
+ ```
123
+
124
+ ## DeepInfra
125
+
126
+ Or try Mistral from [Deepinfra](https://deepinfra.com/mistralai/Mistral-7B-Instruct-v0.1/api?example=openai-http):
127
+
128
+ > Note, apiKey can either be set custom per endpoint, or globally using `OPENAI_API_KEY` variable.
129
+
130
+ ```ini
131
+ MODELS=`[{
132
+ "name": "mistral-7b",
133
+ "displayName": "Mistral 7B",
134
+ "description": "A 7B dense Transformer, fast-deployed and easily customisable. Small, yet powerful for a variety of use cases. Supports English and code, and a 8k context window.",
135
+ "parameters": {
136
+ "temperature": 0.5,
137
+ "max_new_tokens": 4096,
138
+ },
139
+ "endpoints": [
140
+ {
141
+ "type": "openai",
142
+ "baseURL": "https://api.deepinfra.com/v1/openai",
143
+ "apiKey": "abc...xyz"
144
+ }
145
+ ]
146
+ }]`
147
+ ```
148
+
149
+ _Non-streaming endpoints_
150
+
151
+ For endpoints that don´t support streaming like o1 on Azure, you can pass `streamingSupported: false` in your endpoint config:
152
+
153
+ ```
154
+ MODELS=`[{
155
+ "id": "o1-preview",
156
+ "name": "o1-preview",
157
+ "displayName": "o1-preview",
158
+ "systemRoleSupported": false,
159
+ "endpoints": [
160
+ {
161
+ "type": "openai",
162
+ "baseURL": "https://my-deployment.openai.azure.com/openai/deployments/o1-preview",
163
+ "defaultHeaders": {
164
+ "api-key": "$SECRET"
165
+ },
166
+ "streamingSupported": false,
167
+ }
168
+ ]
169
+ }]`
170
+ ```
171
+
172
+ ## Other
173
+
174
+ Some other providers and their `baseURL` for reference.
175
+
176
+ [Groq](https://groq.com/): https://api.groq.com/openai/v1
177
+ [Fireworks](https://fireworks.ai/): https://api.fireworks.ai/inference/v1
178
+
179
+ ```
180
+
181
+ ```
docs/source/configuration/models/providers/tgi.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Text Generation Inference (TGI)
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | Yes\* |
6
+ | [Multimodal](../multimodal) | Yes\* |
7
+
8
+ \* Tools are only supported with the Cohere Command R+ model with the Xenova tokenizers. Please see the [Tools](../tools) section.
9
+
10
+ \* Multimodal is only supported with the IDEFICS model. Please see the [Multimodal](../multimodal) section.
11
+
12
+ By default, if `endpoints` are left unspecified, Chat UI will look for the model on the hosted Hugging Face inference API using the model name, and use your `HF_TOKEN`. Refer to the [overview](../overview) for more information about model configuration.
13
+
14
+ ```ini
15
+ MODELS=`[
16
+ {
17
+ "name": "mistralai/Mistral-7B-Instruct-v0.2",
18
+ "displayName": "mistralai/Mistral-7B-Instruct-v0.2",
19
+ "description": "Mistral 7B is a new Apache 2.0 model, released by Mistral AI that outperforms Llama2 13B in benchmarks.",
20
+ "websiteUrl": "https://mistral.ai/news/announcing-mistral-7b/",
21
+ "preprompt": "",
22
+ "chatPromptTemplate" : "<s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{#if @root.preprompt}}{{@root.preprompt}}\n{{/if}}{{/if}}{{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s>{{/ifAssistant}}{{/each}}",
23
+ "parameters": {
24
+ "temperature": 0.3,
25
+ "top_p": 0.95,
26
+ "repetition_penalty": 1.2,
27
+ "top_k": 50,
28
+ "truncate": 3072,
29
+ "max_new_tokens": 1024,
30
+ "stop": ["</s>"]
31
+ },
32
+ "promptExamples": [
33
+ {
34
+ "title": "Write an email",
35
+ "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)"
36
+ }, {
37
+ "title": "Code a game",
38
+ "prompt": "Code a basic snake game in python, give explanations for each step."
39
+ }, {
40
+ "title": "Recipe help",
41
+ "prompt": "How do I make a delicious lemon cheesecake?"
42
+ }
43
+ ]
44
+ }
45
+ ]`
46
+ ```
47
+
48
+ ## Running your own models using a custom endpoint
49
+
50
+ If you want to, instead of hitting models on the Hugging Face Inference API, you can run your own models locally.
51
+
52
+ A good option is to hit a [text-generation-inference](https://github.com/huggingface/text-generation-inference) endpoint. This is what is done in the official [Chat UI Spaces Docker template](https://huggingface.co/new-space?template=huggingchat/chat-ui-template) for instance: both this app and a text-generation-inference server run inside the same container.
53
+
54
+ To do this, you can add your own endpoints to the `MODELS` variable in `.env.local`, by adding an `"endpoints"` key for each model in `MODELS`.
55
+
56
+ ```ini
57
+ MODELS=`[{
58
+ "name": "your-model-name",
59
+ "displayName": "Your Model Name",
60
+ ... other model config
61
+ "endpoints": [{
62
+ "type" : "tgi",
63
+ "url": "https://HOST:PORT",
64
+ }]
65
+ }]`
66
+ ```
docs/source/configuration/models/tools.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tools
2
+
3
+ Tool calling instructs the model to generate an output matching a user-defined schema, which may be parsed for invoking external tools. The model simply chooses the tools and their parameters. Currently, only `TGI` and `Cohere` with `Command R+` are supported.
4
+
5
+ <div class="flex justify-center">
6
+ <img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/tools-light.png" height="auto"/>
7
+ <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/tools-dark.png" height="auto"/>
8
+ </div>
9
+
10
+ ## TGI Configuration
11
+
12
+ A custom tokenizer is required for prompting the model for generating tool calls, as well as prompting with the results. The expected format for these tools and the resulting tool calls are hard coded for TGI, so it's likely that only the following configuration will work:
13
+
14
+ ```ini
15
+ MODELS=`[
16
+ {
17
+ "name" : "CohereForAI/c4ai-command-r-plus",
18
+ "displayName": "Command R+",
19
+ "description": "Command R+ is Cohere's latest LLM and is the first open weight model to beat GPT4 in the Chatbot Arena!",
20
+ "tools": true,
21
+ "tokenizer": "Xenova/c4ai-command-r-v01-tokenizer",
22
+ "modelUrl": "https://huggingface.co/CohereForAI/c4ai-command-r-plus",
23
+ "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
24
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
25
+ "parameters": {
26
+ "stop": ["<|END_OF_TURN_TOKEN|>"],
27
+ "truncate" : 28672,
28
+ "max_new_tokens" : 4096,
29
+ "temperature" : 0.3
30
+ }
31
+ }
32
+ ]`
33
+ ```
34
+
35
+ ## Cohere Configuration
36
+
37
+ The Cohere provider supports the endpoint native method of tool calling. Refer to the `endpoints/cohere` for implementation details.
38
+
39
+ ```ini
40
+ MODELS=`[
41
+ {
42
+ "name": "command-r-plus",
43
+ "displayName": "Command R+",
44
+ "description": "Command R+ is Cohere's latest LLM and is the first open weight model to beat GPT4 in the Chatbot Arena!",
45
+ "tools": true,
46
+ "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
47
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
48
+ "endpoints": [{
49
+ "type": "cohere",
50
+ "apiKey": "YOUR_API_KEY"
51
+ }]
52
+ }
53
+ ]`
54
+ ```
55
+
56
+ ## Adding Tools
57
+
58
+ Tool implementations are placed in `src/lib/server/tools`, with helpers available for easy integration with HuggingFace Zero GPU spaces. In the future, there may be an OpenAPI interface for adding tools.
59
+
60
+ ## Adding Support for Additional Models
61
+
62
+ The TGI implementation uses a custom tokenizer and hard coded schema for supporting tools. The Cohere implementation, on the other hand, uses the native support in the SDK to emit tool calls. This is the recommended way to add support for more models. Please see the `endpoints/cohere` section of the code for implementation details.
docs/source/configuration/open-id.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenID
2
+
3
+ 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:
4
+
5
+ ```ini
6
+ OPENID_CONFIG=`{
7
+ PROVIDER_URL: "<your OIDC issuer>",
8
+ CLIENT_ID: "<your OIDC client ID>",
9
+ CLIENT_SECRET: "<your OIDC client secret>",
10
+ SCOPES: "openid profile",
11
+ TOLERANCE: // optional
12
+ RESOURCE: // optional
13
+ }`
14
+ ```
15
+
16
+ Redirect URI: `/login/callback`
docs/source/configuration/overview.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration Overview
2
+
3
+ Chat UI handles configuration with environment variables. The default config for Chat UI is stored in the `.env` file, which you may use as a reference. You will need to override some values to get Chat UI to run locally. This can be done in `.env.local` or via your environment. The bare minimum configuration to get Chat UI running is:
4
+
5
+ ```ini
6
+ MONGODB_URL=mongodb://localhost:27017
7
+ HF_TOKEN=your_token
8
+ ```
9
+
10
+ The following sections detail various sections of the app you may want to configure.
docs/source/configuration/theming.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Theming
2
+
3
+ You can use a few environment variables to customize the look and feel of Chat UI. These are by default:
4
+
5
+ ```ini
6
+ PUBLIC_APP_NAME=ChatUI
7
+ PUBLIC_APP_ASSETS=chatui
8
+ PUBLIC_APP_COLOR=blue
9
+ PUBLIC_APP_DESCRIPTION="Making the community's best AI chat models available to everyone."
10
+ PUBLIC_APP_DATA_SHARING=
11
+ PUBLIC_APP_DISCLAIMER=
12
+ ```
13
+
14
+ - `PUBLIC_APP_NAME` The name used as a title throughout the app.
15
+ - `PUBLIC_APP_ASSETS` Is used to find logos & favicons in `static/$PUBLIC_APP_ASSETS`, current options are `chatui` and `huggingchat`.
16
+ - `PUBLIC_APP_COLOR` Can be any of the [tailwind colors](https://tailwindcss.com/docs/customizing-colors#default-color-palette).
17
+ - `PUBLIC_APP_DATA_SHARING` Can be set to 1 to add a toggle in the user settings that lets your users opt-in to data sharing with models creator.
18
+ - `PUBLIC_APP_DISCLAIMER` If set to 1, we show a disclaimer about generated outputs on login.
docs/source/configuration/web-search.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Web Search
2
+
3
+ Chat UI features a powerful Web Search feature. A high level overview of how it works:
4
+
5
+ 1. Generate an appropriate search query from the user prompt using the `TASK_MODEL`
6
+ 2. Perform web search via an external provider (i.e. Serper) or via locally scrape Google results
7
+ 3. Load each search result into playwright and scrape
8
+ 4. Convert scraped HTML to Markdown tree with headings as parents
9
+ 5. Create embeddings for each Markdown element
10
+ 6. Find the embedings clossest to the user query using a vector similarity search (inner product)
11
+ 7. Get the corresponding Markdown elements and their parent, up to 8000 characters
12
+ 8. Supply the information as context to the model
13
+
14
+ <div class="flex justify-center">
15
+ <img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/websearch-light.png" height="auto"/>
16
+ <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/websearch-dark.png" height="auto"/>
17
+ </div>
18
+
19
+ ## Providers
20
+
21
+ Many providers are supported for the web search, or you can use locally scraped Google results.
22
+
23
+ ### Local
24
+
25
+ For locally scraped Google results, put `USE_LOCAL_WEBSEARCH=true` in your `.env.local`. Please note that you may hit rate limits as we make no attempt to make the traffic look legitimate. To avoid this, you may choose a provider, such as Serper, used on the official instance.
26
+
27
+ ### SearXNG
28
+
29
+ > SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
30
+
31
+ You may enable support via the `SEARXNG_QUERY_URL` where `<query>` will be replaceed with the query keywords. Please see [the official documentation](https://docs.searxng.org/dev/search_api.html) for more information
32
+
33
+ Example: `https://searxng.yourdomain.com/search?q=<query>&engines=duckduckgo,google&format=json`
34
+
35
+ ### Third Party
36
+
37
+ Many third party providers are supported as well. The official instance uses Serper.
38
+
39
+ ```ini
40
+ YDC_API_KEY=docs.you.com api key here
41
+ SERPER_API_KEY=serper.dev api key here
42
+ SERPAPI_KEY=serpapi key here
43
+ SERPSTACK_API_KEY=serpstack api key here
44
+ SEARCHAPI_KEY=searchapi api key here
45
+ ```
46
+
47
+ ## Block/Allow List
48
+
49
+ You may block or allow specific websites from the web search results. When using an allow list, only the links in the allowlist will be used. For supported search engines, the links will be blocked from the results directly. Any URL in the results that **partially or fully matches** the entry will be filtered out.
50
+
51
+ ```ini
52
+ WEBSEARCH_BLOCKLIST=`["youtube.com", "https://example.com/foo/bar"]`
53
+ WEBSEARCH_ALLOWLIST=`["stackoverflow.com"]`
54
+ ```
55
+
56
+ ## Disabling Javascript
57
+
58
+ By default, Playwright will execute all Javascript on the page. This can be intensive, requiring up to 6 cores for full performance, on some webpages. You may block scripts from running by settings `WEBSEARCH_JAVASCRIPT=false`. However, this will not block Javascript inlined in the HTML.
docs/source/developing/architecture.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Architecture
2
+
3
+ This document discusses the high level overview of the Chat UI codebase. If you're looking to contribute or just want to understand how the codebase works, this is the place for you!
4
+
5
+ ## Overview
6
+
7
+ Chat UI provides a simple interface connecting LLMs to external information and tools. The project uses [MongoDB](https://www.mongodb.com/) and [SvelteKit](https://kit.svelte.dev/) with [Tailwind](https://tailwindcss.com/).
8
+
9
+ ## Code Map
10
+
11
+ This section discusses various modules of the codebase briefly. The headings are not paths since the codebase structure may change.
12
+
13
+ ### `routes`
14
+
15
+ Provides all of the routes rendered with SSR via SvelteKit. The majority of backend and frontend logic can be found here, with some modules being pulled out into `lib` for the client and `lib/server` for the server.
16
+
17
+ ### `textGeneration`
18
+
19
+ Provides a standard interface for most chat features such as model output, web search, assistants and tools. Outputs `MessageUpdate`s which provide fine-grained updates on the request status such as new tokens and web search results.
20
+
21
+ ### `endpoints`/`embeddingEndpoints`
22
+
23
+ Provides a common streaming interface for many third party LLM and embedding providers.
24
+
25
+ ### `websearch`
26
+
27
+ Implements web search querying and RAG. See the [Web Search](../configuration/web-search) section for more information.
28
+
29
+ ### `tools`
30
+
31
+ Provides a common interface for external tools called by LLMs. See the [Tools](../configuration/models/tools.md) section for more information
32
+
33
+ ### `migrations`
34
+
35
+ Includes all MongoDB migrations for maintaining backwards compatibility across schema changes. Any changes to the schema must include a migration
docs/source/developing/copy-huggingchat.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copy HuggingChat
2
+
3
+ The config file for HuggingChat is stored in the `chart/env/prod.yaml` file. It is the source of truth for the environment variables used for our CI/CD pipeline. For HuggingChat, as we need to customize the app color, as well as the base path, we build a custom docker image. You can find the workflow here.
4
+
5
+ <Tip>
6
+
7
+ If you want to make changes to the model config used in production for HuggingChat, you should do so against `chart/env/prod.yaml`.
8
+
9
+ </Tip>
10
+
11
+ ### Running a copy of HuggingChat locally
12
+
13
+ If you want to run an exact copy of HuggingChat locally, you will need to do the following first:
14
+
15
+ 1. Create an [OAuth App on the hub](https://huggingface.co/settings/applications/new) with `openid profile email` permissions. Make sure to set the callback URL to something like `http://localhost:5173/chat/login/callback` which matches the right path for your local instance.
16
+ 2. Create a [HF Token](https://huggingface.co/settings/tokens) with your Hugging Face account. You will need a Pro account to be able to access some of the larger models available through HuggingChat.
17
+ 3. Create a free account with [serper.dev](https://serper.dev/) (you will get 2500 free search queries)
18
+ 4. Run an instance of MongoDB, however you want. (Local or remote)
19
+
20
+ You can then create a new `.env.SECRET_CONFIG` file with the following content
21
+
22
+ ```ini
23
+ MONGODB_URL=<link to your mongo DB from step 4>
24
+ HF_TOKEN=<your HF token from step 2>
25
+ OPENID_CONFIG=`{
26
+ PROVIDER_URL: "https://huggingface.co",
27
+ CLIENT_ID: "<your client ID from step 1>",
28
+ CLIENT_SECRET: "<your client secret from step 1>",
29
+ }`
30
+ SERPER_API_KEY=<your serper API key from step 3>
31
+ MESSAGES_BEFORE_LOGIN=<can be any numerical value, or set to 0 to require login>
32
+ ```
33
+
34
+ You can then run `npm run updateLocalEnv` in the root of chat-ui. This will create a `.env.local` file which combines the `chart/env/prod.yaml` and the `.env.SECRET_CONFIG` file. You can then run `npm run dev` to start your local instance of HuggingChat.
35
+
36
+ ### Populate database
37
+
38
+ <Tip warning={true}>
39
+
40
+ The `MONGODB_URL` used for this script will be fetched from `.env.local`. Make sure it's correct! The command runs directly on the database.
41
+
42
+ </Tip>
43
+
44
+ You can populate the database using faker data using the `populate` script:
45
+
46
+ ```bash
47
+ npm run populate <flags here>
48
+ ```
49
+
50
+ At least one flag must be specified, the following flags are available:
51
+
52
+ - `reset` - resets the database
53
+ - `all` - populates all tables
54
+ - `users` - populates the users table
55
+ - `settings` - populates the settings table for existing users
56
+ - `assistants` - populates the assistants table for existing users
57
+ - `conversations` - populates the conversations table for existing users
58
+
59
+ For example, you could use it like so:
60
+
61
+ ```bash
62
+ npm run populate reset
63
+ ```
64
+
65
+ to clear out the database. Then login in the app to create your user and run the following command:
66
+
67
+ ```bash
68
+ npm run populate users settings assistants conversations
69
+ ```
70
+
71
+ to populate the database with fake data, including fake conversations and assistants for your user.
docs/source/index.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🤗 Chat UI
2
+
3
+ Open source chat interface with support for tools, web search, multimodal and many API providers. The app uses MongoDB and SvelteKit behind the scenes. Try the live version of the app called [HuggingChat on hf.co/chat](https://huggingface.co/chat) or [setup your own instance](./installation/spaces).
4
+
5
+ 🔧 **[Tools](./configuration/models/tools)**: Function calling with custom tools and support for [Zero GPU spaces](https://huggingface.co/spaces/enzostvs/zero-gpu-spaces)
6
+
7
+ 🔍 **[Web Search](./configuration/web-search)**: Automated web search, scraping and RAG for all models
8
+
9
+ 🐙 **[Multimodal](./configuration/models/multimodal)**: Accepts image file uploads on supported providers
10
+
11
+ 👤 **[OpenID](./configuration/open-id)**: Optionally setup OpenID for user authentication
12
+
13
+ <div class="flex gap-x-4">
14
+
15
+ <div>
16
+ Tools
17
+ <div class="flex justify-center">
18
+ <img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/tools-light.png" height="auto"/>
19
+ <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/tools-dark.png" height="auto"/>
20
+ </div>
21
+ </div>
22
+
23
+ <div>
24
+ Web Search
25
+ <div class="flex justify-center">
26
+ <img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/websearch-light.png" height="auto"/>
27
+ <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/websearch-dark.png" height="auto"/>
28
+ </div>
29
+ </div>
30
+
31
+ </div>
32
+
33
+ ## Quickstart
34
+
35
+ You can quickly have a locally running chat-ui & LLM text-generation server thanks to chat-ui's [llama.cpp server support](https://huggingface.co/docs/chat-ui/configuration/models/providers/llamacpp).
36
+
37
+ **Step 1 (Start llama.cpp server):**
38
+
39
+ ```bash
40
+ # install llama.cpp
41
+ brew install llama.cpp
42
+ # start llama.cpp server (using hf.co/microsoft/Phi-3-mini-4k-instruct-gguf as an example)
43
+ llama-server --hf-repo microsoft/Phi-3-mini-4k-instruct-gguf --hf-file Phi-3-mini-4k-instruct-q4.gguf -c 4096
44
+ ```
45
+
46
+ A local LLaMA.cpp HTTP Server will start on `http://localhost:8080`. Read more [here](https://huggingface.co/docs/chat-ui/configuration/models/providers/llamacpp).
47
+
48
+ **Step 2 (tell chat-ui to use local llama.cpp server):**
49
+
50
+ Add the following to your `.env.local`:
51
+
52
+ ```ini
53
+ MODELS=`[
54
+ {
55
+ "name": "Local microsoft/Phi-3-mini-4k-instruct-gguf",
56
+ "tokenizer": "microsoft/Phi-3-mini-4k-instruct-gguf",
57
+ "preprompt": "",
58
+ "chatPromptTemplate": "<s>{{preprompt}}{{#each messages}}{{#ifUser}}<|user|>\n{{content}}<|end|>\n<|assistant|>\n{{/ifUser}}{{#ifAssistant}}{{content}}<|end|>\n{{/ifAssistant}}{{/each}}",
59
+ "parameters": {
60
+ "stop": ["<|end|>", "<|endoftext|>", "<|assistant|>"],
61
+ "temperature": 0.7,
62
+ "max_new_tokens": 1024,
63
+ "truncate": 3071
64
+ },
65
+ "endpoints": [{
66
+ "type" : "llamacpp",
67
+ "baseURL": "http://localhost:8080"
68
+ }],
69
+ },
70
+ ]`
71
+ ```
72
+
73
+ Read more [here](https://huggingface.co/docs/chat-ui/configuration/models/providers/llamacpp).
74
+
75
+ **Step 3 (make sure you have MongoDb running locally):**
76
+
77
+ ```bash
78
+ docker run -d -p 27017:27017 --name mongo-chatui mongo:latest
79
+ ```
80
+
81
+ Read more [here](https://github.com/huggingface/chat-ui?tab=Readme-ov-file#database).
82
+
83
+ **Step 4 (start chat-ui):**
84
+
85
+ ```bash
86
+ git clone https://github.com/huggingface/chat-ui
87
+ cd chat-ui
88
+ npm install
89
+ npm run dev -- --open
90
+ ```
91
+
92
+ Read more [here](https://github.com/huggingface/chat-ui?tab=readme-ov-file#launch).
93
+
94
+ <div class="flex justify-center">
95
+ <img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/llamacpp-light.png" height="auto"/>
96
+ <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chat-ui/llamacpp-dark.png" height="auto"/>
97
+ </div>
docs/source/installation/docker.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Running on Docker
2
+
3
+ Pre-built docker images are provided with and without MongoDB built in. Refer to the [configuration section](../configuration/overview) for env variables that must be provided. We recommend using the `--env-file` option to avoid leaking secrets into your shell history.
4
+
5
+ ```bash
6
+ # Without built-in DB
7
+ docker run -p 3000:3000 --env-file .env.local --name chat-ui ghcr.io/huggingface/chat-ui
8
+
9
+ # With built-in DB
10
+ docker run -p 3000:3000 --env-file .env.local -v chat-ui:/data --name chat-ui ghcr.io/huggingface/chat-ui-db
11
+ ```
docs/source/installation/helm.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Helm
2
+
3
+ <Tip warning={true}>
4
+
5
+ **We highly discourage using the chart**. The Helm chart is a work in progress and should be considered unstable. Breaking changes to the chart may be pushed without migration guides or notice. Contributions welcome!
6
+
7
+ </Tip>
8
+
9
+ For installation on Kubernetes, you may use the helm chart in `/chart`. Please note that no chart repository has been setup, so you'll need to clone the repository and install the chart by path. The production values may be found at `chart/env/prod.yaml`.
10
+
11
+ **Example values.yaml**
12
+
13
+ ```yaml
14
+ replicas: 1
15
+
16
+ domain: example.com
17
+
18
+ service:
19
+ type: ClusterIP
20
+
21
+ resources:
22
+ requests:
23
+ cpu: 100m
24
+ memory: 2Gi
25
+ limits:
26
+ # Recommended to use large limits when web search is enabled
27
+ cpu: "4"
28
+ memory: 6Gi
29
+
30
+ envVars:
31
+ MONGODB_URL: mongodb://chat-ui-mongo:27017
32
+ # Ensure that your values.yaml will not leak anywhere
33
+ # PRs welcome for a chart rework with envFrom support!
34
+ HF_TOKEN: secret_token
35
+ ```
docs/source/installation/local.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Running Locally
2
+
3
+ You may start an instance locally for non-production use cases. For production use cases, please see the other installation options.
4
+
5
+ ## Configuration
6
+
7
+ 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. Start by creating a `.env.local` file in the root of the repository as per the [configuration section](../configuration/overview). The bare minimum config you need to get Chat UI to run locally is the following:
8
+
9
+ ```ini
10
+ MONGODB_URL=<the URL to your MongoDB instance>
11
+ HF_TOKEN=<your access token> # find your token at hf.co/settings/token
12
+ ```
13
+
14
+ ## Database
15
+
16
+ The chat history is stored in a MongoDB instance, and having a DB instance available is needed for Chat UI to work.
17
+
18
+ You can use a local MongoDB instance. The easiest way is to spin one up using docker with persistence:
19
+
20
+ ```bash
21
+ docker run -d -p 27017:27017 -v mongo-chat-ui:/data --name mongo-chat-ui mongo:latest
22
+ ```
23
+
24
+ In which case the url of your DB will be `MONGODB_URL=mongodb://localhost:27017`.
25
+
26
+ Alternatively, you can use a [free MongoDB Atlas](https://www.mongodb.com/pricing) instance for this, Chat UI should fit comfortably within their free tier. After which you can set the `MONGODB_URL` variable in `.env.local` to match your instance.
27
+
28
+ ## Starting the server
29
+
30
+ ```bash
31
+ npm ci # install dependencies
32
+ npm run build # build the project
33
+ npm run preview -- --open # start the server with & open your instance at http://localhost:4173
34
+ ```
docs/source/installation/spaces.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Running on Huggingface Spaces
2
+
3
+ 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.
4
+
5
+ You can deploy your own customized Chat UI instance with any supported [LLM](https://huggingface.co/models?pipeline_tag=text-generation) of your choice on [Hugging Face Spaces](https://huggingface.co/spaces). To do so, use the chat-ui template [available here](https://huggingface.co/new-space?template=huggingchat/chat-ui-template).
6
+
7
+ Set `HF_TOKEN` in [Space secrets](https://huggingface.co/docs/hub/spaces-overview#managing-secrets-and-environment-variables) to deploy a model with gated access or a model in a private repository. It's also compatible with [Inference for PROs](https://huggingface.co/blog/inference-pro) curated list of powerful models with higher rate limits. Make sure to create your personal token first in your [User Access Tokens settings](https://huggingface.co/settings/tokens).
8
+
9
+ Read the full tutorial [here](https://huggingface.co/docs/hub/spaces-sdks-docker-chatui#chatui-on-spaces).
entrypoint.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ENV_LOCAL_PATH=/app/.env.local
2
+
3
+ if test -z "${DOTENV_LOCAL}" ; then
4
+ if ! test -f "${ENV_LOCAL_PATH}" ; then
5
+ echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. Make sure to set environment variables properly. "
6
+ fi;
7
+ else
8
+ echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
9
+ cat <<< "$DOTENV_LOCAL" > ${ENV_LOCAL_PATH}
10
+ fi;
11
+
12
+ if [ "$INCLUDE_DB" = "true" ] ; then
13
+ echo "Starting local MongoDB instance"
14
+ nohup mongod &
15
+ fi;
16
+
17
+ export PUBLIC_VERSION=$(node -p "require('./package.json').version")
18
+
19
+ dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000
models/add-your-models-here.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ You can add .gguf files to this folder, and they will be picked up automatically by chat-ui.
package.json ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "chat-ui",
3
+ "version": "0.9.4",
4
+ "private": true,
5
+ "packageManager": "npm@9.5.0",
6
+ "scripts": {
7
+ "dev": "vite dev",
8
+ "build": "vite build",
9
+ "preview": "vite preview",
10
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12
+ "lint": "prettier --check . && eslint .",
13
+ "format": "prettier --write .",
14
+ "test": "vitest",
15
+ "updateLocalEnv": "vite-node --options.transformMode.ssr='/.*/' scripts/updateLocalEnv.ts",
16
+ "populate": "vite-node --options.transformMode.ssr='/.*/' scripts/populate.ts",
17
+ "config": "vite-node --options.transformMode.ssr='/.*/' scripts/config.ts",
18
+ "prepare": "husky"
19
+ },
20
+ "devDependencies": {
21
+ "@faker-js/faker": "^8.4.1",
22
+ "@iconify-json/carbon": "^1.1.16",
23
+ "@iconify-json/eos-icons": "^1.1.6",
24
+ "@sveltejs/adapter-node": "^5.2.12",
25
+ "@sveltejs/kit": "^2.20.7",
26
+ "@sveltejs/vite-plugin-svelte": "^5.0.3",
27
+ "@tailwindcss/typography": "^0.5.9",
28
+ "@types/dompurify": "^3.0.5",
29
+ "@types/express": "^4.17.21",
30
+ "@types/fs-extra": "^11.0.4",
31
+ "@types/js-yaml": "^4.0.9",
32
+ "@types/jsdom": "^21.1.1",
33
+ "@types/jsonpath": "^0.2.4",
34
+ "@types/katex": "^0.16.7",
35
+ "@types/mime-types": "^2.1.4",
36
+ "@types/minimist": "^1.2.5",
37
+ "@types/node": "^22.1.0",
38
+ "@types/parquetjs": "^0.10.3",
39
+ "@types/sbd": "^1.0.5",
40
+ "@types/uuid": "^9.0.8",
41
+ "@typescript-eslint/eslint-plugin": "^6.x",
42
+ "@typescript-eslint/parser": "^6.x",
43
+ "dompurify": "^3.2.4",
44
+ "eslint": "^8.28.0",
45
+ "eslint-config-prettier": "^8.5.0",
46
+ "eslint-plugin-svelte": "^2.45.1",
47
+ "fs-extra": "^11.3.0",
48
+ "isomorphic-dompurify": "^2.13.0",
49
+ "js-yaml": "^4.1.0",
50
+ "minimist": "^1.2.8",
51
+ "mongodb-memory-server": "^10.1.2",
52
+ "node-llama-cpp": "^3.6.0",
53
+ "prettier": "^3.1.0",
54
+ "prettier-plugin-svelte": "^3.2.6",
55
+ "prettier-plugin-tailwindcss": "^0.6.11",
56
+ "prom-client": "^15.1.2",
57
+ "sade": "^1.8.1",
58
+ "svelte": "^5.27.0",
59
+ "svelte-check": "^4.0.0",
60
+ "svelte-gestures": "^5.1.3",
61
+ "ts-node": "^10.9.1",
62
+ "tslib": "^2.4.1",
63
+ "typescript": "^5.5.0",
64
+ "unplugin-icons": "^0.16.1",
65
+ "vite": "^6.2.6",
66
+ "vite-node": "^3.0.9",
67
+ "vitest": "^3.0.9"
68
+ },
69
+ "type": "module",
70
+ "dependencies": {
71
+ "@aws-sdk/credential-providers": "^3.592.0",
72
+ "@cliqz/adblocker-playwright": "^1.34.0",
73
+ "@gradio/client": "^1.8.0",
74
+ "@huggingface/hub": "^0.5.1",
75
+ "@huggingface/inference": "^2.8.1",
76
+ "@huggingface/transformers": "^3.1.1",
77
+ "@iconify-json/bi": "^1.1.21",
78
+ "@playwright/browser-chromium": "^1.43.1",
79
+ "@resvg/resvg-js": "^2.6.2",
80
+ "autoprefixer": "^10.4.14",
81
+ "aws-sigv4-fetch": "^4.0.1",
82
+ "aws4": "^1.13.0",
83
+ "date-fns": "^2.29.3",
84
+ "dotenv": "^16.5.0",
85
+ "express": "^4.21.2",
86
+ "file-type": "^19.4.1",
87
+ "google-auth-library": "^9.13.0",
88
+ "handlebars": "^4.7.8",
89
+ "highlight.js": "^11.7.0",
90
+ "husky": "^9.0.11",
91
+ "image-size": "^1.2.1",
92
+ "ip-address": "^9.0.5",
93
+ "jose": "^5.3.0",
94
+ "jsdom": "^22.0.0",
95
+ "json5": "^2.2.3",
96
+ "jsonpath": "^1.1.1",
97
+ "katex": "^0.16.21",
98
+ "lint-staged": "^15.2.7",
99
+ "marked": "^12.0.1",
100
+ "mongodb": "^5.8.0",
101
+ "nanoid": "^5.0.9",
102
+ "openid-client": "^5.4.2",
103
+ "parquetjs": "^0.11.2",
104
+ "pino": "^9.0.0",
105
+ "pino-pretty": "^11.0.0",
106
+ "playwright": "^1.52.0",
107
+ "postcss": "^8.4.31",
108
+ "saslprep": "^1.0.3",
109
+ "satori": "^0.10.11",
110
+ "satori-html": "^0.3.2",
111
+ "sbd": "^1.0.19",
112
+ "serpapi": "^1.1.1",
113
+ "sharp": "^0.33.4",
114
+ "tailwind-scrollbar": "^3.0.0",
115
+ "tailwindcss": "^3.4.0",
116
+ "uuid": "^10.0.0",
117
+ "zod": "^3.22.3"
118
+ },
119
+ "optionalDependencies": {
120
+ "@anthropic-ai/sdk": "^0.32.1",
121
+ "@anthropic-ai/vertex-sdk": "^0.4.1",
122
+ "@aws-sdk/client-bedrock-runtime": "^3.631.0",
123
+ "@google-cloud/vertexai": "^1.1.0",
124
+ "@google/generative-ai": "^0.24.0",
125
+ "aws4fetch": "^1.0.17",
126
+ "cohere-ai": "^7.9.0",
127
+ "openai": "^4.44.0"
128
+ },
129
+ "overrides": {
130
+ "@reflink/reflink": "file:stub/@reflink/reflink"
131
+ }
132
+ }
scripts/config.ts ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sade from "sade";
2
+
3
+ // @ts-expect-error: vite-node makes the var available but the typescript compiler doesn't see them
4
+ import { config, ready } from "$lib/server/config";
5
+
6
+ const prog = sade("config");
7
+ await ready;
8
+ prog
9
+ .command("clear")
10
+ .describe("Clear all config keys")
11
+ .action(async () => {
12
+ console.log("Clearing config...");
13
+ await clear();
14
+ });
15
+
16
+ prog
17
+ .command("add <key> <value>")
18
+ .describe("Add a new config key")
19
+ .action(async (key: string, value: string) => {
20
+ await add(key, value);
21
+ });
22
+
23
+ prog
24
+ .command("remove <key>")
25
+ .describe("Remove a config key")
26
+ .action(async (key: string) => {
27
+ console.log(`Removing ${key}`);
28
+ await remove(key);
29
+ process.exit(0);
30
+ });
31
+
32
+ prog
33
+ .command("help")
34
+ .describe("Show help information")
35
+ .action(() => {
36
+ prog.help();
37
+ process.exit(0);
38
+ });
39
+
40
+ async function clear() {
41
+ await config.clear();
42
+ process.exit(0);
43
+ }
44
+
45
+ async function add(key: string, value: string) {
46
+ if (!key || !value) {
47
+ console.error("Key and value are required");
48
+ process.exit(1);
49
+ }
50
+ await config.set(key as keyof typeof config.keysFromEnv, value);
51
+ process.exit(0);
52
+ }
53
+
54
+ async function remove(key: string) {
55
+ if (!key) {
56
+ console.error("Key is required");
57
+ process.exit(1);
58
+ }
59
+ await config.delete(key as keyof typeof config.keysFromEnv);
60
+ process.exit(0);
61
+ }
62
+
63
+ // Parse arguments and handle help automatically
64
+ prog.parse(process.argv);
scripts/populate.ts ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import readline from "readline";
2
+ import minimist from "minimist";
3
+
4
+ // @ts-expect-error: vite-node makes the var available but the typescript compiler doesn't see them
5
+ import { env } from "$env/dynamic/private";
6
+
7
+ import { faker } from "@faker-js/faker";
8
+ import { ObjectId } from "mongodb";
9
+
10
+ // @ts-expect-error: vite-node makes the var available but the typescript compiler doesn't see them
11
+ import { ready } from "$lib/server/config";
12
+ import { collections } from "$lib/server/database.ts";
13
+ import { models } from "../src/lib/server/models.ts";
14
+ import type { User } from "../src/lib/types/User";
15
+ import type { Assistant } from "../src/lib/types/Assistant";
16
+ import type { Conversation } from "../src/lib/types/Conversation";
17
+ import type { Settings } from "../src/lib/types/Settings";
18
+ import type { CommunityToolDB, ToolLogoColor, ToolLogoIcon } from "../src/lib/types/Tool";
19
+ import { defaultEmbeddingModel } from "../src/lib/server/embeddingModels.ts";
20
+ import { Message } from "../src/lib/types/Message.ts";
21
+
22
+ import { addChildren } from "../src/lib/utils/tree/addChildren.ts";
23
+ import { generateSearchTokens } from "../src/lib/utils/searchTokens.ts";
24
+ import { ReviewStatus } from "../src/lib/types/Review.ts";
25
+ import fs from "fs";
26
+ import path from "path";
27
+ import { MessageUpdateType } from "../src/lib/types/MessageUpdate.ts";
28
+ import { MessageReasoningUpdateType } from "../src/lib/types/MessageUpdate.ts";
29
+
30
+ const rl = readline.createInterface({
31
+ input: process.stdin,
32
+ output: process.stdout,
33
+ });
34
+
35
+ await ready;
36
+
37
+ rl.on("close", function () {
38
+ process.exit(0);
39
+ });
40
+
41
+ const samples = fs.readFileSync(path.join(__dirname, "samples.txt"), "utf8").split("\n---\n");
42
+
43
+ const possibleFlags = ["reset", "all", "users", "settings", "assistants", "conversations", "tools"];
44
+ const argv = minimist(process.argv.slice(2));
45
+ const flags = argv["_"].filter((flag) => possibleFlags.includes(flag));
46
+
47
+ async function generateMessages(preprompt?: string): Promise<Message[]> {
48
+ const isLinear = faker.datatype.boolean(0.5);
49
+ const isInterrupted = faker.datatype.boolean(0.05);
50
+
51
+ const messages: Message[] = [];
52
+
53
+ messages.push({
54
+ id: crypto.randomUUID(),
55
+ from: "system",
56
+ content: preprompt ?? "",
57
+ createdAt: faker.date.recent({ days: 30 }),
58
+ updatedAt: faker.date.recent({ days: 30 }),
59
+ });
60
+
61
+ let isUser = true;
62
+ let lastId = messages[0].id;
63
+ if (isLinear) {
64
+ const convLength = faker.number.int({ min: 1, max: 25 }) * 2; // must always be even
65
+
66
+ for (let i = 0; i < convLength; i++) {
67
+ const hasReasoning = Math.random() < 0.2;
68
+ lastId = addChildren(
69
+ {
70
+ messages,
71
+ rootMessageId: messages[0].id,
72
+ },
73
+ {
74
+ from: isUser ? "user" : "assistant",
75
+ content:
76
+ faker.lorem.sentence({
77
+ min: 10,
78
+ max: isUser ? 50 : 200,
79
+ }) +
80
+ (!isUser && Math.random() < 0.1
81
+ ? "\n```\n" + faker.helpers.arrayElement(samples) + "\n```\n"
82
+ : ""),
83
+ createdAt: faker.date.recent({ days: 30 }),
84
+ updatedAt: faker.date.recent({ days: 30 }),
85
+ reasoning: hasReasoning ? faker.lorem.paragraphs(2) : undefined,
86
+ updates: hasReasoning
87
+ ? [
88
+ {
89
+ type: MessageUpdateType.Reasoning,
90
+ subtype: MessageReasoningUpdateType.Status,
91
+ uuid: crypto.randomUUID(),
92
+ status: "thinking",
93
+ },
94
+ ]
95
+ : [],
96
+ interrupted: !isUser && i === convLength - 1 && isInterrupted,
97
+ },
98
+ lastId
99
+ );
100
+ isUser = !isUser;
101
+ }
102
+ } else {
103
+ const convLength = faker.number.int({ min: 2, max: 200 });
104
+
105
+ for (let i = 0; i < convLength; i++) {
106
+ const hasReasoning = Math.random() < 0.2;
107
+ addChildren(
108
+ {
109
+ messages,
110
+ rootMessageId: messages[0].id,
111
+ },
112
+ {
113
+ from: isUser ? "user" : "assistant",
114
+ content:
115
+ faker.lorem.sentence({
116
+ min: 10,
117
+ max: isUser ? 50 : 200,
118
+ }) +
119
+ (!isUser && Math.random() < 0.1
120
+ ? "\n```\n" + faker.helpers.arrayElement(samples) + "\n```\n"
121
+ : ""),
122
+ reasoning: hasReasoning ? faker.lorem.paragraphs(2) : undefined,
123
+ updates: hasReasoning
124
+ ? [
125
+ {
126
+ type: MessageUpdateType.Reasoning,
127
+ subtype: MessageReasoningUpdateType.Status,
128
+ uuid: crypto.randomUUID(),
129
+ status: "thinking",
130
+ },
131
+ ]
132
+ : [],
133
+ createdAt: faker.date.recent({ days: 30 }),
134
+ updatedAt: faker.date.recent({ days: 30 }),
135
+ interrupted: !isUser && i === convLength - 1 && isInterrupted,
136
+ },
137
+ faker.helpers.arrayElement([
138
+ messages[0].id,
139
+ ...messages.filter((m) => m.from === (isUser ? "assistant" : "user")).map((m) => m.id),
140
+ ])
141
+ );
142
+
143
+ isUser = !isUser;
144
+ }
145
+ }
146
+ return messages;
147
+ }
148
+
149
+ async function seed() {
150
+ console.log("Seeding...");
151
+ const modelIds = models.map((model) => model.id);
152
+
153
+ if (flags.includes("reset")) {
154
+ console.log("Starting reset of DB");
155
+ await collections.users.deleteMany({});
156
+ await collections.settings.deleteMany({});
157
+ await collections.assistants.deleteMany({});
158
+ await collections.conversations.deleteMany({});
159
+ await collections.tools.deleteMany({});
160
+ await collections.migrationResults.deleteMany({});
161
+ await collections.semaphores.deleteMany({});
162
+ console.log("Reset done");
163
+ }
164
+
165
+ if (flags.includes("users") || flags.includes("all")) {
166
+ console.log("Creating 100 new users");
167
+ const newUsers: User[] = Array.from({ length: 100 }, () => ({
168
+ _id: new ObjectId(),
169
+ createdAt: faker.date.recent({ days: 30 }),
170
+ updatedAt: faker.date.recent({ days: 30 }),
171
+ username: faker.internet.userName(),
172
+ name: faker.person.fullName(),
173
+ hfUserId: faker.string.alphanumeric(24),
174
+ avatarUrl: faker.image.avatar(),
175
+ }));
176
+
177
+ await collections.users.insertMany(newUsers);
178
+ console.log("Done creating users.");
179
+ }
180
+
181
+ const users = await collections.users.find().toArray();
182
+ if (flags.includes("settings") || flags.includes("all")) {
183
+ console.log("Updating settings for all users");
184
+ users.forEach(async (user) => {
185
+ const settings: Settings = {
186
+ userId: user._id,
187
+ shareConversationsWithModelAuthors: faker.datatype.boolean(0.25),
188
+ hideEmojiOnSidebar: faker.datatype.boolean(0.25),
189
+ ethicsModalAcceptedAt: faker.date.recent({ days: 30 }),
190
+ activeModel: faker.helpers.arrayElement(modelIds),
191
+ createdAt: faker.date.recent({ days: 30 }),
192
+ updatedAt: faker.date.recent({ days: 30 }),
193
+ disableStream: faker.datatype.boolean(0.25),
194
+ directPaste: faker.datatype.boolean(0.25),
195
+ customPrompts: {},
196
+ assistants: [],
197
+ };
198
+ await collections.settings.updateOne(
199
+ { userId: user._id },
200
+ { $set: { ...settings } },
201
+ { upsert: true }
202
+ );
203
+ });
204
+ console.log("Done updating settings.");
205
+ }
206
+
207
+ if (flags.includes("assistants") || flags.includes("all")) {
208
+ console.log("Creating assistants for all users");
209
+ await Promise.all(
210
+ users.map(async (user) => {
211
+ const name = faker.animal.insect();
212
+ const assistants = faker.helpers.multiple<Assistant>(
213
+ () => ({
214
+ _id: new ObjectId(),
215
+ name,
216
+ createdById: user._id,
217
+ createdByName: user.username,
218
+ createdAt: faker.date.recent({ days: 30 }),
219
+ updatedAt: faker.date.recent({ days: 30 }),
220
+ userCount: faker.number.int({ min: 1, max: 100000 }),
221
+ review: faker.helpers.enumValue(ReviewStatus),
222
+ modelId: faker.helpers.arrayElement(modelIds),
223
+ description: faker.lorem.sentence(),
224
+ preprompt: faker.hacker.phrase(),
225
+ exampleInputs: faker.helpers.multiple(() => faker.lorem.sentence(), {
226
+ count: faker.number.int({ min: 0, max: 4 }),
227
+ }),
228
+ searchTokens: generateSearchTokens(name),
229
+ last24HoursCount: faker.number.int({ min: 0, max: 1000 }),
230
+ }),
231
+ { count: faker.number.int({ min: 3, max: 10 }) }
232
+ );
233
+ await collections.assistants.insertMany(assistants);
234
+ await collections.settings.updateOne(
235
+ { userId: user._id },
236
+ { $set: { assistants: assistants.map((a) => a._id.toString()) } },
237
+ { upsert: true }
238
+ );
239
+ })
240
+ );
241
+ console.log("Done creating assistants.");
242
+ }
243
+
244
+ if (flags.includes("conversations") || flags.includes("all")) {
245
+ console.log("Creating conversations for all users");
246
+ await Promise.all(
247
+ users.map(async (user) => {
248
+ const conversations = faker.helpers.multiple(
249
+ async () => {
250
+ const settings = await collections.settings.findOne<Settings>({ userId: user._id });
251
+
252
+ const assistantId =
253
+ settings?.assistants && settings.assistants.length > 0 && faker.datatype.boolean(0.1)
254
+ ? faker.helpers.arrayElement<ObjectId>(settings.assistants)
255
+ : undefined;
256
+
257
+ const preprompt =
258
+ (assistantId
259
+ ? await collections.assistants
260
+ .findOne({ _id: assistantId })
261
+ .then((assistant: Assistant) => assistant?.preprompt ?? "")
262
+ : faker.helpers.maybe(() => faker.hacker.phrase(), { probability: 0.5 })) ?? "";
263
+
264
+ const messages = await generateMessages(preprompt);
265
+
266
+ const conv = {
267
+ _id: new ObjectId(),
268
+ userId: user._id,
269
+ assistantId,
270
+ preprompt,
271
+ createdAt: faker.date.recent({ days: 145 }),
272
+ updatedAt: faker.date.recent({ days: 145 }),
273
+ model: faker.helpers.arrayElement(modelIds),
274
+ title: faker.internet.emoji() + " " + faker.hacker.phrase(),
275
+ embeddingModel: defaultEmbeddingModel.id,
276
+ messages,
277
+ rootMessageId: messages[0].id,
278
+ } satisfies Conversation;
279
+
280
+ return conv;
281
+ },
282
+ { count: faker.number.int({ min: 10, max: 200 }) }
283
+ );
284
+
285
+ await collections.conversations.insertMany(await Promise.all(conversations));
286
+ })
287
+ );
288
+ console.log("Done creating conversations.");
289
+ }
290
+
291
+ // generate Community Tools
292
+ if (flags.includes("tools") || flags.includes("all")) {
293
+ const tools = await Promise.all(
294
+ faker.helpers.multiple(
295
+ () => {
296
+ const _id = new ObjectId();
297
+ const displayName = faker.company.catchPhrase();
298
+ const description = faker.company.catchPhrase();
299
+ const color = faker.helpers.arrayElement([
300
+ "purple",
301
+ "blue",
302
+ "green",
303
+ "yellow",
304
+ "red",
305
+ ]) satisfies ToolLogoColor;
306
+ const icon = faker.helpers.arrayElement([
307
+ "wikis",
308
+ "tools",
309
+ "camera",
310
+ "code",
311
+ "email",
312
+ "cloud",
313
+ "terminal",
314
+ "game",
315
+ "chat",
316
+ "speaker",
317
+ "video",
318
+ ]) satisfies ToolLogoIcon;
319
+ const baseUrl = faker.helpers.arrayElement([
320
+ "stabilityai/stable-diffusion-3-medium",
321
+ "multimodalart/cosxl",
322
+ "gokaygokay/SD3-Long-Captioner",
323
+ "xichenhku/MimicBrush",
324
+ ]);
325
+
326
+ // keep empty for populate for now
327
+
328
+ const user: User = faker.helpers.arrayElement(users);
329
+ const createdById = user._id;
330
+ const createdByName = user.username ?? user.name;
331
+
332
+ return {
333
+ type: "community" as const,
334
+ _id,
335
+ createdById,
336
+ createdByName,
337
+ displayName,
338
+ name: displayName.toLowerCase().replace(" ", "_"),
339
+ endpoint: "/test",
340
+ description,
341
+ color,
342
+ icon,
343
+ baseUrl,
344
+ inputs: [],
345
+ outputPath: null,
346
+ outputType: "str" as const,
347
+ showOutput: false,
348
+ useCount: faker.number.int({ min: 0, max: 100000 }),
349
+ last24HoursUseCount: faker.number.int({ min: 0, max: 1000 }),
350
+ createdAt: faker.date.recent({ days: 30 }),
351
+ updatedAt: faker.date.recent({ days: 30 }),
352
+ searchTokens: generateSearchTokens(displayName),
353
+ review: faker.helpers.enumValue(ReviewStatus),
354
+ outputComponent: null,
355
+ outputComponentIdx: null,
356
+ };
357
+ },
358
+ { count: faker.number.int({ min: 10, max: 200 }) }
359
+ )
360
+ );
361
+
362
+ await collections.tools.insertMany(tools satisfies CommunityToolDB[]);
363
+ }
364
+ }
365
+
366
+ // run seed
367
+ (async () => {
368
+ try {
369
+ rl.question(
370
+ "You're about to run a seeding script on the following MONGODB_URL: \x1b[31m" +
371
+ env.MONGODB_URL +
372
+ "\x1b[0m\n\n With the following flags: \x1b[31m" +
373
+ flags.join("\x1b[0m , \x1b[31m") +
374
+ "\x1b[0m\n \n\n Are you sure you want to continue? (yes/no): ",
375
+ async (confirm) => {
376
+ if (confirm !== "yes") {
377
+ console.log("Not 'yes', exiting.");
378
+ rl.close();
379
+ process.exit(0);
380
+ }
381
+ console.log("Starting seeding...");
382
+ await seed();
383
+ console.log("Seeding done.");
384
+ rl.close();
385
+ }
386
+ );
387
+ } catch (e) {
388
+ console.error(e);
389
+ process.exit(1);
390
+ }
391
+ })();
scripts/samples.txt ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Observable, of, from, interval, throwError } from 'rxjs';
2
+ import { map, filter, catchError, switchMap, take, tap } from 'rxjs/operators';
3
+
4
+ // Mock function to fetch stock prices (simulates API call)
5
+ const fetchStockPrice = (ticker: string): Observable<number> => {
6
+ return new Observable<number>((observer) => {
7
+ const intervalId = setInterval(() => {
8
+ if (Math.random() < 0.1) { // Simulating an error 10% of the time
9
+ observer.error(`Error fetching stock price for ${ticker}`);
10
+ } else {
11
+ const price = parseFloat((Math.random() * 1000).toFixed(2));
12
+ observer.next(price);
13
+ }
14
+ }, 1000);
15
+
16
+ return () => {
17
+ clearInterval(intervalId);
18
+ console.log(`Stopped fetching prices for ${ticker}`);
19
+ };
20
+ });
21
+ };
22
+
23
+ // Example usage: Tracking stock price updates
24
+ const stockTicker = 'AAPL';
25
+ const stockPrice$ = fetchStockPrice(stockTicker).pipe(
26
+ map(price => ({ ticker: stockTicker, price })), // Transform data
27
+ filter(data => data.price > 500), // Only keep prices above 500
28
+ tap(data => console.log(`Price update:`, data)), // Side effect: Logging
29
+ catchError(err => {
30
+ console.error(err);
31
+ return of({ ticker: stockTicker, price: null }); // Fallback observable
32
+ })
33
+ );
34
+
35
+ // Subscribe to the stock price updates
36
+ const subscription = stockPrice$.subscribe({
37
+ next: data => console.log(`Subscriber received:`, data),
38
+ error: err => console.error(`Subscription error:`, err),
39
+ complete: () => console.log('Stream complete'),
40
+ });
41
+
42
+ // Automatically unsubscribe after 10 seconds
43
+ setTimeout(() => {
44
+ subscription.unsubscribe();
45
+ console.log('Unsubscribed from stock price updates.');
46
+ }, 10000);
47
+ ---
48
+ class EnforceAttrsMeta(type):
49
+ """
50
+ Metaclass that enforces the presence of specific attributes in a class
51
+ and automatically decorates methods with a logging wrapper.
52
+ """
53
+
54
+ required_attributes = ['name', 'version']
55
+
56
+ def __new__(cls, name, bases, class_dict):
57
+ """
58
+ Create a new class with enforced attributes and method logging.
59
+
60
+ :param name: Name of the class being created.
61
+ :param bases: Tuple of base classes.
62
+ :param class_dict: Dictionary of attributes and methods of the class.
63
+ :return: Newly created class object.
64
+ """
65
+ # Ensure required attributes exist
66
+ for attr in cls.required_attributes:
67
+ if attr not in class_dict:
68
+ raise TypeError(f"Class '{name}' is missing required attribute '{attr}'")
69
+
70
+ # Wrap all methods in a logging decorator
71
+ for key, value in class_dict.items():
72
+ if callable(value): # Check if it's a method
73
+ class_dict[key] = cls.log_calls(value)
74
+
75
+ return super().__new__(cls, name, bases, class_dict)
76
+
77
+ @staticmethod
78
+ def log_calls(func):
79
+ """
80
+ Decorator that logs method calls and arguments.
81
+
82
+ :param func: Function to be wrapped.
83
+ :return: Wrapped function with logging.
84
+ """
85
+ def wrapper(*args, **kwargs):
86
+ print(f"Calling {func.__name__} with args={args} kwargs={kwargs}")
87
+ result = func(*args, **kwargs)
88
+ print(f"{func.__name__} returned {result}")
89
+ return result
90
+ return wrapper
91
+
92
+
93
+ class PluginBase(metaclass=EnforceAttrsMeta):
94
+ """
95
+ Base class for plugins that enforces required attributes and logging.
96
+ """
97
+ name = "BasePlugin"
98
+ version = "1.0"
99
+
100
+ def run(self, data):
101
+ """
102
+ Process the input data.
103
+
104
+ :param data: The data to be processed.
105
+ :return: Processed result.
106
+ """
107
+ return f"Processed {data}"
108
+
109
+
110
+ class CustomPlugin(PluginBase):
111
+ """
112
+ Custom plugin that extends PluginBase and adheres to enforced rules.
113
+ """
114
+ name = "CustomPlugin"
115
+ version = "2.0"
116
+
117
+ def run(self, data):
118
+ """
119
+ Custom processing logic.
120
+
121
+ :param data: The data to process.
122
+ :return: Modified data.
123
+ """
124
+ return f"Custom processing of {data}"
125
+
126
+
127
+ # Uncommenting the following class definition will raise a TypeError
128
+ # because 'version' attribute is missing.
129
+ # class InvalidPlugin(PluginBase):
130
+ # name = "InvalidPlugin"
131
+
132
+
133
+ if __name__ == "__main__":
134
+ # Instantiate and use the plugin
135
+ plugin = CustomPlugin()
136
+ print(plugin.run("example data"))
137
+ ---
138
+ <!DOCTYPE html>
139
+ <html lang="en">
140
+ <head>
141
+ <meta charset="UTF-8">
142
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
143
+ <title>Click the Box Game</title>
144
+ <style>
145
+ body {
146
+ text-align: center;
147
+ font-family: Arial, sans-serif;
148
+ }
149
+ #game-container {
150
+ position: relative;
151
+ width: 300px;
152
+ height: 300px;
153
+ margin: 20px auto;
154
+ border: 2px solid black;
155
+ overflow: hidden;
156
+ }
157
+ #target {
158
+ width: 50px;
159
+ height: 50px;
160
+ background-color: red;
161
+ position: absolute;
162
+ cursor: pointer;
163
+ }
164
+ </style>
165
+ </head>
166
+ <body>
167
+ <h1>Click the Box!</h1>
168
+ <p>Score: <span id="score">0</span></p>
169
+ <div id="game-container">
170
+ <div id="target"></div>
171
+ </div>
172
+ <script>
173
+ let score = 0;
174
+ const target = document.getElementById("target");
175
+ const scoreDisplay = document.getElementById("score");
176
+ const container = document.getElementById("game-container");
177
+
178
+ function moveTarget() {
179
+ const maxX = container.clientWidth - target.clientWidth;
180
+ const maxY = container.clientHeight - target.clientHeight;
181
+ target.style.left = Math.random() * maxX + "px";
182
+ target.style.top = Math.random() * maxY + "px";
183
+ }
184
+
185
+ target.addEventListener("click", function() {
186
+ score++;
187
+ scoreDisplay.textContent = score;
188
+ moveTarget();
189
+ });
190
+
191
+ moveTarget();
192
+ </script>
193
+ </body>
194
+ </html>
scripts/setupTest.ts ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { vi, afterAll } from "vitest";
2
+ import dotenv from "dotenv";
3
+ import { resolve } from "path";
4
+ import fs from "fs";
5
+ import { MongoMemoryServer } from "mongodb-memory-server";
6
+
7
+ let mongoServer: MongoMemoryServer;
8
+ // Load the .env file
9
+ const envPath = resolve(__dirname, "../.env");
10
+ dotenv.config({ path: envPath });
11
+
12
+ // Read the .env file content
13
+ const envContent = fs.readFileSync(envPath, "utf-8");
14
+
15
+ // Parse the .env content
16
+ const envVars = dotenv.parse(envContent);
17
+
18
+ // Separate public and private variables
19
+ const publicEnv = {};
20
+ const privateEnv = {};
21
+
22
+ for (const [key, value] of Object.entries(envVars)) {
23
+ if (key.startsWith("PUBLIC_")) {
24
+ publicEnv[key] = value;
25
+ } else {
26
+ privateEnv[key] = value;
27
+ }
28
+ }
29
+
30
+ vi.mock("$env/dynamic/public", () => ({
31
+ env: publicEnv,
32
+ }));
33
+
34
+ vi.mock("$env/dynamic/private", async () => {
35
+ mongoServer = await MongoMemoryServer.create();
36
+
37
+ return {
38
+ env: {
39
+ ...privateEnv,
40
+ MONGODB_URL: mongoServer.getUri(),
41
+ },
42
+ };
43
+ });
44
+
45
+ afterAll(async () => {
46
+ if (mongoServer) {
47
+ await mongoServer.stop();
48
+ }
49
+ });