Liam Dyer mishig HF Staff commited on
Commit
b88a126
·
unverified ·
1 Parent(s): 0fcb8db

Hosted Documentation (#1155)

Browse files

* docs: switch to dedicated docs

* ci: docs PR preview

* feat: move docs to docs/source and format

* docs: switch to using <Tip>

* docs: misc

* ci: build documentation for prod workflow

* docs: simplify readme

* style: format markdown

* docs: minor clarifications

* push main as well

* DD UPLOAD ACTION

* test trigger

* format

* update doc trigger paths

* follow transformers release branch naming

---------

Co-authored-by: Mishig Davaadorj <[email protected]>

Files changed (31) hide show
  1. .github/workflows/build-docs.yml +18 -0
  2. .github/workflows/build-pr-docs.yml +20 -0
  3. .github/workflows/upload-pr-documentation.yml +16 -0
  4. README.md +5 -13
  5. docs/source/_toctree.yml +62 -0
  6. docs/source/configuration/common-issues.md +7 -0
  7. docs/source/configuration/embeddings.md +82 -0
  8. docs/source/configuration/models/multimodal.md +24 -0
  9. docs/source/configuration/models/overview.md +147 -0
  10. docs/source/configuration/models/providers/anthropic.md +117 -0
  11. docs/source/configuration/models/providers/aws.md +35 -0
  12. docs/source/configuration/models/providers/cloudflare.md +41 -0
  13. docs/source/configuration/models/providers/cohere.md +26 -0
  14. docs/source/configuration/models/providers/google.md +49 -0
  15. docs/source/configuration/models/providers/langserve.md +22 -0
  16. docs/source/configuration/models/providers/llamacpp.md +38 -0
  17. docs/source/configuration/models/providers/ollama.md +39 -0
  18. docs/source/configuration/models/providers/openai.md +135 -0
  19. docs/source/configuration/models/providers/tgi.md +66 -0
  20. docs/source/configuration/models/tools.md +57 -0
  21. docs/source/configuration/open-id.md +16 -0
  22. docs/source/configuration/overview.md +10 -0
  23. docs/source/configuration/theming.md +18 -0
  24. docs/source/configuration/web-search.md +52 -0
  25. docs/source/developing/architecture.md +35 -0
  26. docs/source/developing/copy-huggingchat.md +71 -0
  27. docs/source/index.md +11 -0
  28. docs/source/installation/docker.md +11 -0
  29. docs/source/installation/helm.md +35 -0
  30. docs/source/installation/local.md +34 -0
  31. docs/source/installation/spaces.md +9 -0
.github/workflows/build-docs.yml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - v*-release
8
+
9
+ jobs:
10
+ build:
11
+ uses: huggingface/doc-builder/.github/workflows/build_main_documentation.yml@main
12
+ with:
13
+ commit_sha: ${{ github.sha }}
14
+ package: chat-ui
15
+ additional_args: --not_python_module
16
+ secrets:
17
+ token: ${{ secrets.HUGGINGFACE_PUSH }}
18
+ hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}
.github/workflows/build-pr-docs.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build PR Documentation
2
+
3
+ on:
4
+ pull_request:
5
+ paths:
6
+ - "docs/source/**"
7
+ - ".github/workflows/build-pr-docs.yml"
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ build:
15
+ uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@main
16
+ with:
17
+ commit_sha: ${{ github.event.pull_request.head.sha }}
18
+ pr_number: ${{ github.event.number }}
19
+ package: chat-ui
20
+ additional_args: --not_python_module
.github/workflows/upload-pr-documentation.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Upload PR Documentation
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: ["Build PR Documentation"]
6
+ types:
7
+ - completed
8
+
9
+ jobs:
10
+ build:
11
+ uses: huggingface/doc-builder/.github/workflows/upload_pr_documentation.yml@main
12
+ with:
13
+ package_name: chat-ui
14
+ secrets:
15
+ hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}
16
+ comment_bot_token: ${{ secrets.COMMENT_BOT_TOKEN }}
README.md CHANGED
@@ -16,23 +16,15 @@ load_balancing_strategy: random
16
 
17
  ![Chat UI repository thumbnail](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chatui-websearch.png)
18
 
19
- A chat interface using open source models, eg OpenAssistant or Llama. It is a SvelteKit app and it powers the [HuggingChat app on hf.co/chat](https://huggingface.co/chat).
20
 
21
- 0. [No Setup Deploy](#no-setup-deploy)
22
- 1. [Setup](#setup)
23
- 2. [Launch](#launch)
24
- 3. [Web Search](#web-search)
25
- 4. [Text Embedding Models](#text-embedding-models)
26
- 5. [Extra parameters](#extra-parameters)
27
- 6. [Common issues](#common-issues)
28
- 7. [Deploying to a HF Space](#deploying-to-a-hf-space)
29
- 8. [Building](#building)
30
 
31
- ## No Setup Deploy
32
 
33
- 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.
34
 
35
- You can deploy your own customized Chat UI instance with any supported [LLM](https://huggingface.co/models?pipeline_tag=text-generation&sort=trending) 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).
36
 
37
  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).
38
 
 
16
 
17
  ![Chat UI repository thumbnail](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chatui-websearch.png)
18
 
19
+ 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](https://huggingface.co/docs/chat-ui/installation/spaces).
20
 
21
+ 🔧 **Tools**: Function calling with custom tools and support for [Zero GPU spaces](https://huggingface.co/spaces/enzostvs/zero-gpu-spaces)
 
 
 
 
 
 
 
 
22
 
23
+ 🔍 **Web Search**: Automated web search, scraping and RAG for all models
24
 
25
+ 🐙 **Multimodal**: Accepts image file uploads on supported providers
26
 
27
+ 👤 **OpenID**: Optionally setup OpenID for user authentication
28
 
29
  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).
30
 
docs/source/_toctree.yml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/embeddings
24
+ title: Text Embedding Models
25
+ - title: Models
26
+ sections:
27
+ - local: configuration/models/overview
28
+ title: Overview
29
+ - local: configuration/models/multimodal
30
+ title: Multimodal
31
+ - local: configuration/models/tools
32
+ title: Tools
33
+ - title: Providers
34
+ sections:
35
+ - local: configuration/models/providers/anthropic
36
+ title: Anthropic
37
+ - local: configuration/models/providers/aws
38
+ title: AWS
39
+ - local: configuration/models/providers/cloudflare
40
+ title: Cloudflare
41
+ - local: configuration/models/providers/cohere
42
+ title: Cohere
43
+ - local: configuration/models/providers/google
44
+ title: Google
45
+ - local: configuration/models/providers/langserve
46
+ title: Langserve
47
+ - local: configuration/models/providers/llamacpp
48
+ title: Llama.cpp
49
+ - local: configuration/models/providers/ollama
50
+ title: Ollama
51
+ - local: configuration/models/providers/openai
52
+ title: OpenAI
53
+ - local: configuration/models/providers/tgi
54
+ title: TGI
55
+ - local: configuration/common-issues
56
+ title: Common Issues
57
+ - title: Developing
58
+ sections:
59
+ - local: developing/architecture
60
+ title: Architecture
61
+ - local: developing/copy-huggingchat
62
+ 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,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ Please contribute an example!
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 from bullet list",
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 snake game",
29
+ "prompt": "Code a basic snake game in python, give explanations for each step."
30
+ }, {
31
+ "title": "Assist in a task",
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,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ```
36
+
37
+ <Tip warning={true}>
38
+
39
+ Cloudlare Workers AI currently do not support custom sampling parameters like temperature, top_p, etc.
40
+
41
+ </Tip>
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,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "model": "gemini-1.5-pro-preview-0409", // model-name
37
+
38
+ // Optional
39
+ "safetyThreshold": "BLOCK_MEDIUM_AND_ABOVE",
40
+ "apiEndpoint": "", // alternative api endpoint url,
41
+ "tools": [{
42
+ "googleSearchRetrieval": {
43
+ "disableAttribution": true
44
+ }
45
+ }]
46
+ }]
47
+ },
48
+ ]`
49
+ ```
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,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Zephyr as an example model:
11
+
12
+ 1. Get [the weights](https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/tree/main) from the hub
13
+ 2. Run the server with the following command: `./server -m models/zephyr-7b-beta.Q4_K_M.gguf -c 2048 -np 3`
14
+ 3. Add the following to your `.env.local`:
15
+
16
+ ```ini
17
+ MODELS=`[
18
+ {
19
+ "name": "Local Zephyr",
20
+ "chatPromptTemplate": "<|system|>\n{{preprompt}}</s>\n{{#each messages}}{{#ifUser}}<|user|>\n{{content}}</s>\n<|assistant|>\n{{/ifUser}}{{#ifAssistant}}{{content}}</s>\n{{/ifAssistant}}{{/each}}",
21
+ "parameters": {
22
+ "temperature": 0.1,
23
+ "top_p": 0.95,
24
+ "repetition_penalty": 1.2,
25
+ "top_k": 50,
26
+ "truncate": 1000,
27
+ "max_new_tokens": 2048,
28
+ "stop": ["</s>"]
29
+ },
30
+ "endpoints": [
31
+ {
32
+ "url": "http://127.0.0.1:8080",
33
+ "type": "llamacpp"
34
+ }
35
+ ]
36
+ }
37
+ ]`
38
+ ```
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,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenAI
2
+
3
+ | Feature | Available |
4
+ | --------------------------- | --------- |
5
+ | [Tools](../tools) | No |
6
+ | [Multimodal](../multimodal) | No |
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).
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
+ 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:
57
+
58
+ ```ini
59
+ MODELS=`[{
60
+ "name": "claude-2.1",
61
+ "displayName": "Claude 2.1",
62
+ "description": "Anthropic has been founded by former OpenAI researchers...",
63
+ "parameters": {
64
+ "temperature": 0.5,
65
+ "max_new_tokens": 4096,
66
+ },
67
+ "endpoints": [
68
+ {
69
+ "type": "openai",
70
+ "baseURL": "https://gateway.example.com/v1",
71
+ "defaultHeaders": {
72
+ "x-portkey-config": '{"provider":"anthropic","api_key":"sk-ant-abc...xyz"}'
73
+ }
74
+ }
75
+ ]
76
+ }]`
77
+ ```
78
+
79
+ Example for GPT 4 deployed on Azure OpenAI:
80
+
81
+ ```ini
82
+ MODELS=`[{
83
+ "id": "gpt-4-1106-preview",
84
+ "name": "gpt-4-1106-preview",
85
+ "displayName": "gpt-4-1106-preview",
86
+ "parameters": {
87
+ "temperature": 0.5,
88
+ "max_new_tokens": 4096,
89
+ },
90
+ "endpoints": [
91
+ {
92
+ "type": "openai",
93
+ "baseURL": "https://{resource-name}.openai.azure.com/openai/deployments/{deployment-id}",
94
+ "defaultHeaders": {
95
+ "api-key": "{api-key}"
96
+ },
97
+ "defaultQuery": {
98
+ "api-version": "2023-05-15"
99
+ }
100
+ }
101
+ ]
102
+ }]`
103
+ ```
104
+
105
+ ## DeepInfra
106
+
107
+ Or try Mistral from [Deepinfra](https://deepinfra.com/mistralai/Mistral-7B-Instruct-v0.1/api?example=openai-http):
108
+
109
+ > Note, apiKey can either be set custom per endpoint, or globally using `OPENAI_API_KEY` variable.
110
+
111
+ ```ini
112
+ MODELS=`[{
113
+ "name": "mistral-7b",
114
+ "displayName": "Mistral 7B",
115
+ "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.",
116
+ "parameters": {
117
+ "temperature": 0.5,
118
+ "max_new_tokens": 4096,
119
+ },
120
+ "endpoints": [
121
+ {
122
+ "type": "openai",
123
+ "baseURL": "https://api.deepinfra.com/v1/openai",
124
+ "apiKey": "abc...xyz"
125
+ }
126
+ ]
127
+ }]`
128
+ ```
129
+
130
+ ## Other
131
+
132
+ Some other providers and their `baseURL` for reference.
133
+
134
+ [Groq](https://groq.com/): https://api.groq.com/openai/v1
135
+ [Fireworks](https://fireworks.ai/): https://api.fireworks.ai/inference/v1
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](/configuration/models/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 from bullet list",
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 snake game",
38
+ "prompt": "Code a basic snake game in python, give explanations for each step."
39
+ }, {
40
+ "title": "Assist in a task",
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,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ## TGI Configuration
6
+
7
+ 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:
8
+
9
+ ```ini
10
+ MODELS=`[
11
+ {
12
+ "name" : "CohereForAI/c4ai-command-r-plus",
13
+ "displayName": "Command R+",
14
+ "description": "Command R+ is Cohere's latest LLM and is the first open weight model to beat GPT4 in the Chatbot Arena!",
15
+ "tools": true,
16
+ "tokenizer": "Xenova/c4ai-command-r-v01-tokenizer",
17
+ "modelUrl": "https://huggingface.co/CohereForAI/c4ai-command-r-plus",
18
+ "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
19
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
20
+ "parameters": {
21
+ "stop": ["<|END_OF_TURN_TOKEN|>"],
22
+ "truncate" : 28672,
23
+ "max_new_tokens" : 4096,
24
+ "temperature" : 0.3
25
+ }
26
+ }
27
+ ]`
28
+ ```
29
+
30
+ ## Cohere Configuration
31
+
32
+ The Cohere provider supports the endpoint native method of tool calling. Refer to the `endpoints/cohere` for implementation details.
33
+
34
+ ```ini
35
+ MODELS=`[
36
+ {
37
+ "name": "command-r-plus",
38
+ "displayName": "Command R+",
39
+ "description": "Command R+ is Cohere's latest LLM and is the first open weight model to beat GPT4 in the Chatbot Arena!",
40
+ "tools": true,
41
+ "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
42
+ "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
43
+ "endpoints": [{
44
+ "type": "cohere",
45
+ "apiKey": "YOUR_API_KEY"
46
+ }]
47
+ }
48
+ ]`
49
+ ```
50
+
51
+ ## Adding Tools
52
+
53
+ 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.
54
+
55
+ ## Adding Support for Additional Models
56
+
57
+ 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,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ## Providers
15
+
16
+ Many providers are supported for the web search, or you can use locally scraped Google results.
17
+
18
+ ### Local
19
+
20
+ 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.
21
+
22
+ ### SearXNG
23
+
24
+ > SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
25
+
26
+ 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
27
+
28
+ Example: `https://searxng.yourdomain.com/search?q=<query>&engines=duckduckgo,google&format=json`
29
+
30
+ ### Third Party
31
+
32
+ Many third party providers are supported as well. The official instance uses Serper.
33
+
34
+ ```ini
35
+ YDC_API_KEY=docs.you.com api key here
36
+ SERPER_API_KEY=serper.dev api key here
37
+ SERPAPI_KEY=serpapi key here
38
+ SERPSTACK_API_KEY=serpstack api key here
39
+ ```
40
+
41
+ ## Block/Allow List
42
+
43
+ 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.
44
+
45
+ ```ini
46
+ WEBSEARCH_BLOCKLIST=`["youtube.com", "https://example.com/foo/bar"]`
47
+ WEBSEARCH_ALLOWLIST=`["stackoverflow.com"]`
48
+ ```
49
+
50
+ ## Disabling Javascript
51
+
52
+ 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) 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,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
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**: Function calling with custom tools and support for [Zero GPU spaces](https://huggingface.co/spaces/enzostvs/zero-gpu-spaces)
6
+
7
+ 🔍 **Web Search**: Automated web search, scraping and RAG for all models
8
+
9
+ 🐙 **Multimodal**: Accepts image file uploads on supported providers
10
+
11
+ 👤 **OpenID**: Optionally setup OpenID for user authentication
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 or use externalSecrets instead
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).