Add documentation
Browse filesIntroduced a new documentation structure under docs/source, covering configuration, installation (local, Docker, Helm), architecture, and common issues. Updated .env and README.md to clarify model discovery and LLM router configuration. This improves onboarding, setup, and operational guidance for developers and users.
- .env +1 -1
- README.md +1 -1
- docs/source/_toctree.yml +30 -0
- docs/source/configuration/common-issues.md +37 -0
- docs/source/configuration/llm-router.md +105 -0
- docs/source/configuration/mcp-tools.md +83 -0
- docs/source/configuration/metrics.md +9 -0
- docs/source/configuration/open-id.md +57 -0
- docs/source/configuration/overview.md +88 -0
- docs/source/configuration/theming.md +20 -0
- docs/source/developing/architecture.md +47 -0
- docs/source/index.md +52 -0
- docs/source/installation/docker.md +43 -0
- docs/source/installation/helm.md +43 -0
- docs/source/installation/local.md +62 -0
.env
CHANGED
|
@@ -54,7 +54,7 @@ TASK_MODEL=
|
|
| 54 |
LLM_ROUTER_ARCH_BASE_URL=
|
| 55 |
|
| 56 |
## LLM Router Configuration
|
| 57 |
-
# Path to routes policy (JSON array).
|
| 58 |
LLM_ROUTER_ROUTES_PATH=
|
| 59 |
|
| 60 |
# Model used at the Arch router endpoint for selection
|
|
|
|
| 54 |
LLM_ROUTER_ARCH_BASE_URL=
|
| 55 |
|
| 56 |
## LLM Router Configuration
|
| 57 |
+
# Path to routes policy (JSON array). Required when the router is enabled; must point to a valid JSON file.
|
| 58 |
LLM_ROUTER_ROUTES_PATH=
|
| 59 |
|
| 60 |
# Model used at the Arch router endpoint for selection
|
README.md
CHANGED
|
@@ -122,7 +122,7 @@ PUBLIC_APP_DATA_SHARING=
|
|
| 122 |
|
| 123 |
### Models
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
### LLM Router (Optional)
|
| 128 |
|
|
|
|
| 122 |
|
| 123 |
### Models
|
| 124 |
|
| 125 |
+
Models are discovered from `${OPENAI_BASE_URL}/models`, and you can optionally override their metadata via the `MODELS` env var (JSON5). Legacy provider‑specific integrations and GGUF discovery are removed. Authorization uses `OPENAI_API_KEY` (preferred). `HF_TOKEN` remains a legacy alias.
|
| 126 |
|
| 127 |
### LLM Router (Optional)
|
| 128 |
|
docs/source/_toctree.yml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- local: index
|
| 2 |
+
title: Chat UI
|
| 3 |
+
- title: Installation
|
| 4 |
+
sections:
|
| 5 |
+
- local: installation/local
|
| 6 |
+
title: Local
|
| 7 |
+
- local: installation/docker
|
| 8 |
+
title: Docker
|
| 9 |
+
- local: installation/helm
|
| 10 |
+
title: Helm
|
| 11 |
+
- title: Configuration
|
| 12 |
+
sections:
|
| 13 |
+
- local: configuration/overview
|
| 14 |
+
title: Overview
|
| 15 |
+
- local: configuration/theming
|
| 16 |
+
title: Theming
|
| 17 |
+
- local: configuration/open-id
|
| 18 |
+
title: OpenID
|
| 19 |
+
- local: configuration/mcp-tools
|
| 20 |
+
title: MCP Tools
|
| 21 |
+
- local: configuration/llm-router
|
| 22 |
+
title: LLM Router
|
| 23 |
+
- local: configuration/metrics
|
| 24 |
+
title: Metrics
|
| 25 |
+
- local: configuration/common-issues
|
| 26 |
+
title: Common Issues
|
| 27 |
+
- title: Developing
|
| 28 |
+
sections:
|
| 29 |
+
- local: developing/architecture
|
| 30 |
+
title: Architecture
|
docs/source/configuration/common-issues.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Common Issues
|
| 2 |
+
|
| 3 |
+
## 403: You don't have access to this conversation
|
| 4 |
+
|
| 5 |
+
This usually happens when running Chat UI over HTTP without proper cookie configuration.
|
| 6 |
+
|
| 7 |
+
**Recommended:** Set up a reverse proxy (NGINX, Caddy) to handle HTTPS.
|
| 8 |
+
|
| 9 |
+
**Alternative:** If you must run over HTTP, configure cookies:
|
| 10 |
+
|
| 11 |
+
```ini
|
| 12 |
+
COOKIE_SECURE=false
|
| 13 |
+
COOKIE_SAMESITE=lax
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
Also ensure `PUBLIC_ORIGIN` matches your actual URL:
|
| 17 |
+
|
| 18 |
+
```ini
|
| 19 |
+
PUBLIC_ORIGIN=http://localhost:5173
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
## Models not loading
|
| 23 |
+
|
| 24 |
+
If models aren't appearing in the UI:
|
| 25 |
+
|
| 26 |
+
1. Verify `OPENAI_BASE_URL` is correct and accessible
|
| 27 |
+
2. Check that `OPENAI_API_KEY` is valid
|
| 28 |
+
3. Ensure the endpoint returns models at `${OPENAI_BASE_URL}/models`
|
| 29 |
+
|
| 30 |
+
## Database connection errors
|
| 31 |
+
|
| 32 |
+
For development, you can skip MongoDB entirely - Chat UI will use an embedded database.
|
| 33 |
+
|
| 34 |
+
For production, verify:
|
| 35 |
+
- `MONGODB_URL` is a valid connection string
|
| 36 |
+
- Your IP is whitelisted (for MongoDB Atlas)
|
| 37 |
+
- The database user has read/write permissions
|
docs/source/configuration/llm-router.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LLM Router
|
| 2 |
+
|
| 3 |
+
Chat UI includes an intelligent routing system that automatically selects the best model for each request. When enabled, users see a virtual "Omni" model that routes to specialized models based on the conversation context.
|
| 4 |
+
|
| 5 |
+
The router uses [katanemo/Arch-Router-1.5B](https://huggingface.co/katanemo/Arch-Router-1.5B) for route selection.
|
| 6 |
+
|
| 7 |
+
## Configuration
|
| 8 |
+
|
| 9 |
+
### Basic Setup
|
| 10 |
+
|
| 11 |
+
```ini
|
| 12 |
+
# Arch router endpoint (OpenAI-compatible)
|
| 13 |
+
LLM_ROUTER_ARCH_BASE_URL=https://router.huggingface.co/v1
|
| 14 |
+
LLM_ROUTER_ARCH_MODEL=katanemo/Arch-Router-1.5B
|
| 15 |
+
|
| 16 |
+
# Path to your routes policy JSON
|
| 17 |
+
LLM_ROUTER_ROUTES_PATH=./config/routes.json
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
### Routes Policy
|
| 21 |
+
|
| 22 |
+
Create a JSON file defining your routes. Each route specifies:
|
| 23 |
+
|
| 24 |
+
```json
|
| 25 |
+
[
|
| 26 |
+
{
|
| 27 |
+
"name": "coding",
|
| 28 |
+
"description": "Programming, debugging, code review",
|
| 29 |
+
"primary_model": "Qwen/Qwen3-Coder-480B-A35B-Instruct",
|
| 30 |
+
"fallback_models": ["meta-llama/Llama-3.3-70B-Instruct"]
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"name": "casual_conversation",
|
| 34 |
+
"description": "General chat, questions, explanations",
|
| 35 |
+
"primary_model": "meta-llama/Llama-3.3-70B-Instruct"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
### Fallback Behavior
|
| 41 |
+
|
| 42 |
+
```ini
|
| 43 |
+
# Route to use when Arch returns "other"
|
| 44 |
+
LLM_ROUTER_OTHER_ROUTE=casual_conversation
|
| 45 |
+
|
| 46 |
+
# Model to use if Arch selection fails entirely
|
| 47 |
+
LLM_ROUTER_FALLBACK_MODEL=meta-llama/Llama-3.3-70B-Instruct
|
| 48 |
+
|
| 49 |
+
# Selection timeout (milliseconds)
|
| 50 |
+
LLM_ROUTER_ARCH_TIMEOUT_MS=10000
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Multimodal Routing
|
| 54 |
+
|
| 55 |
+
When a user sends an image, the router can bypass Arch and route directly to a vision model:
|
| 56 |
+
|
| 57 |
+
```ini
|
| 58 |
+
LLM_ROUTER_ENABLE_MULTIMODAL=true
|
| 59 |
+
LLM_ROUTER_MULTIMODAL_MODEL=meta-llama/Llama-3.2-90B-Vision-Instruct
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Tools Routing
|
| 63 |
+
|
| 64 |
+
When a user has MCP servers enabled, the router can automatically select a tools-capable model:
|
| 65 |
+
|
| 66 |
+
```ini
|
| 67 |
+
LLM_ROUTER_ENABLE_TOOLS=true
|
| 68 |
+
LLM_ROUTER_TOOLS_MODEL=meta-llama/Llama-3.3-70B-Instruct
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## UI Customization
|
| 72 |
+
|
| 73 |
+
Customize how the router appears in the model selector:
|
| 74 |
+
|
| 75 |
+
```ini
|
| 76 |
+
PUBLIC_LLM_ROUTER_ALIAS_ID=omni
|
| 77 |
+
PUBLIC_LLM_ROUTER_DISPLAY_NAME=Omni
|
| 78 |
+
PUBLIC_LLM_ROUTER_LOGO_URL=https://example.com/logo.png
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
## How It Works
|
| 82 |
+
|
| 83 |
+
When a user selects Omni:
|
| 84 |
+
|
| 85 |
+
1. Chat UI sends the conversation context to the Arch router
|
| 86 |
+
2. Arch analyzes the content and returns a route name
|
| 87 |
+
3. Chat UI maps the route to the corresponding model
|
| 88 |
+
4. The request streams from the selected model
|
| 89 |
+
5. On errors, fallback models are tried in order
|
| 90 |
+
|
| 91 |
+
The route selection is displayed in the UI so users can see which model was chosen.
|
| 92 |
+
|
| 93 |
+
## Message Length Limits
|
| 94 |
+
|
| 95 |
+
To optimize router performance, message content is trimmed before sending to Arch:
|
| 96 |
+
|
| 97 |
+
```ini
|
| 98 |
+
# Max characters for assistant messages (default: 500)
|
| 99 |
+
LLM_ROUTER_MAX_ASSISTANT_LENGTH=500
|
| 100 |
+
|
| 101 |
+
# Max characters for previous user messages (default: 400)
|
| 102 |
+
LLM_ROUTER_MAX_PREV_USER_LENGTH=400
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
The latest user message is never trimmed.
|
docs/source/configuration/mcp-tools.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MCP Tools
|
| 2 |
+
|
| 3 |
+
Chat UI supports tool calling via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/). MCP servers expose tools that models can invoke during conversations.
|
| 4 |
+
|
| 5 |
+
## Server Types
|
| 6 |
+
|
| 7 |
+
Chat UI supports two types of MCP servers:
|
| 8 |
+
|
| 9 |
+
### Base Servers (Admin-configured)
|
| 10 |
+
|
| 11 |
+
Base servers are configured by the administrator via environment variables. They appear for all users and can be enabled/disabled per-user but not removed.
|
| 12 |
+
|
| 13 |
+
```ini
|
| 14 |
+
MCP_SERVERS=[
|
| 15 |
+
{"name": "Web Search (Exa)", "url": "https://mcp.exa.ai/mcp"},
|
| 16 |
+
{"name": "Hugging Face", "url": "https://hf.co/mcp"}
|
| 17 |
+
]
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
Each server entry requires:
|
| 21 |
+
- `name` - Display name shown in the UI
|
| 22 |
+
- `url` - MCP server endpoint URL
|
| 23 |
+
- `headers` (optional) - Custom headers for authentication
|
| 24 |
+
|
| 25 |
+
### User Servers (Added from UI)
|
| 26 |
+
|
| 27 |
+
Users can add their own MCP servers directly from the UI:
|
| 28 |
+
|
| 29 |
+
1. Open the chat input and click the **+** button (or go to Settings)
|
| 30 |
+
2. Select **MCP Servers**
|
| 31 |
+
3. Click **Add Server**
|
| 32 |
+
4. Enter the server name and URL
|
| 33 |
+
5. Run **Health Check** to verify connectivity
|
| 34 |
+
|
| 35 |
+
User-added servers are stored in the browser and can be removed at any time. They work alongside base servers.
|
| 36 |
+
|
| 37 |
+
## User Token Forwarding
|
| 38 |
+
|
| 39 |
+
When users are logged in via Hugging Face, you can forward their access token to MCP servers:
|
| 40 |
+
|
| 41 |
+
```ini
|
| 42 |
+
MCP_FORWARD_HF_USER_TOKEN=true
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
This allows MCP servers to access user-specific resources on their behalf.
|
| 46 |
+
|
| 47 |
+
## Using Tools
|
| 48 |
+
|
| 49 |
+
1. Enable the servers you want to use from the MCP Servers panel
|
| 50 |
+
2. Start chatting - models will automatically use tools when appropriate
|
| 51 |
+
|
| 52 |
+
### Model Requirements
|
| 53 |
+
|
| 54 |
+
Not all models support tool calling. To enable tools for a specific model, add it to your `MODELS` override:
|
| 55 |
+
|
| 56 |
+
```ini
|
| 57 |
+
MODELS=`[
|
| 58 |
+
{
|
| 59 |
+
"id": "meta-llama/Llama-3.3-70B-Instruct",
|
| 60 |
+
"supportsTools": true
|
| 61 |
+
}
|
| 62 |
+
]`
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
## Tool Execution Flow
|
| 66 |
+
|
| 67 |
+
When a model decides to use a tool:
|
| 68 |
+
|
| 69 |
+
1. The model generates a tool call with parameters
|
| 70 |
+
2. Chat UI executes the call against the MCP server
|
| 71 |
+
3. Results are displayed in the chat as a collapsible "tool" block
|
| 72 |
+
4. Results are fed back to the model for follow-up responses
|
| 73 |
+
|
| 74 |
+
## Integration with LLM Router
|
| 75 |
+
|
| 76 |
+
When using the [LLM Router](./llm-router), you can configure automatic routing to a tools-capable model:
|
| 77 |
+
|
| 78 |
+
```ini
|
| 79 |
+
LLM_ROUTER_ENABLE_TOOLS=true
|
| 80 |
+
LLM_ROUTER_TOOLS_MODEL=meta-llama/Llama-3.3-70B-Instruct
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
When a user has MCP servers enabled and selects the Omni model, the router will automatically use the specified tools model.
|
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/open-id.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# OpenID
|
| 2 |
+
|
| 3 |
+
By default, users are attributed a unique ID based on their browser session. To authenticate users with OpenID Connect, configure the following:
|
| 4 |
+
|
| 5 |
+
```ini
|
| 6 |
+
OPENID_CLIENT_ID=your_client_id
|
| 7 |
+
OPENID_CLIENT_SECRET=your_client_secret
|
| 8 |
+
OPENID_SCOPES="openid profile"
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
Use the provider URL for standard OpenID Connect discovery:
|
| 12 |
+
|
| 13 |
+
```ini
|
| 14 |
+
OPENID_PROVIDER_URL=https://your-provider.com
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
Advanced: you can also provide a client metadata document via `OPENID_CONFIG`. This value must be a JSON/JSON5 object (for example, a CIMD document) and is parsed server‑side to populate OpenID settings.
|
| 18 |
+
|
| 19 |
+
**Redirect URI:** `https://your-domain.com/login/callback`
|
| 20 |
+
|
| 21 |
+
## Access Control
|
| 22 |
+
|
| 23 |
+
Restrict access to specific users:
|
| 24 |
+
|
| 25 |
+
```ini
|
| 26 |
+
# Allow only specific email addresses
|
| 27 |
+
ALLOWED_USER_EMAILS=["user@example.com", "admin@example.com"]
|
| 28 |
+
|
| 29 |
+
# Allow all users from specific domains
|
| 30 |
+
ALLOWED_USER_DOMAINS=["example.com", "company.org"]
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
## Hugging Face Login
|
| 34 |
+
|
| 35 |
+
For Hugging Face authentication, you can use automatic client registration:
|
| 36 |
+
|
| 37 |
+
```ini
|
| 38 |
+
OPENID_CLIENT_ID=__CIMD__
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
This creates an OAuth app automatically when deployed. See the [CIMD spec](https://datatracker.ietf.org/doc/draft-ietf-oauth-client-id-metadata-document/) for details.
|
| 42 |
+
|
| 43 |
+
## User Token Forwarding
|
| 44 |
+
|
| 45 |
+
When users log in via Hugging Face, you can forward their token for inference:
|
| 46 |
+
|
| 47 |
+
```ini
|
| 48 |
+
USE_USER_TOKEN=true
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## Auto-Login
|
| 52 |
+
|
| 53 |
+
Force authentication on all routes:
|
| 54 |
+
|
| 55 |
+
```ini
|
| 56 |
+
AUTOMATIC_LOGIN=true
|
| 57 |
+
```
|
docs/source/configuration/overview.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Configuration Overview
|
| 2 |
+
|
| 3 |
+
Chat UI is configured through environment variables. Default values are in `.env`; override them in `.env.local` or via your environment.
|
| 4 |
+
|
| 5 |
+
## Required Configuration
|
| 6 |
+
|
| 7 |
+
Chat UI connects to any OpenAI-compatible API endpoint:
|
| 8 |
+
|
| 9 |
+
```ini
|
| 10 |
+
OPENAI_BASE_URL=https://router.huggingface.co/v1
|
| 11 |
+
OPENAI_API_KEY=hf_************************
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
Models are automatically discovered from `${OPENAI_BASE_URL}/models`. No manual model configuration is required.
|
| 15 |
+
|
| 16 |
+
## Database
|
| 17 |
+
|
| 18 |
+
```ini
|
| 19 |
+
MONGODB_URL=mongodb://localhost:27017
|
| 20 |
+
MONGODB_DB_NAME=chat-ui
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
For development, `MONGODB_URL` is optional - Chat UI falls back to an embedded MongoDB that persists to `./db`.
|
| 24 |
+
|
| 25 |
+
## Model Overrides
|
| 26 |
+
|
| 27 |
+
To customize model behavior, use the `MODELS` environment variable (JSON5 format):
|
| 28 |
+
|
| 29 |
+
```ini
|
| 30 |
+
MODELS=`[
|
| 31 |
+
{
|
| 32 |
+
"id": "meta-llama/Llama-3.3-70B-Instruct",
|
| 33 |
+
"name": "Llama 3.3 70B",
|
| 34 |
+
"multimodal": false,
|
| 35 |
+
"supportsTools": true
|
| 36 |
+
}
|
| 37 |
+
]`
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Override properties:
|
| 41 |
+
- `id` - Model identifier (must match an ID from the `/models` endpoint)
|
| 42 |
+
- `name` - Display name in the UI
|
| 43 |
+
- `multimodal` - Enable image uploads
|
| 44 |
+
- `supportsTools` - Enable MCP tool calling for models that don’t advertise tool support
|
| 45 |
+
- `parameters` - Override default parameters (temperature, max_tokens, etc.)
|
| 46 |
+
|
| 47 |
+
## Task Model
|
| 48 |
+
|
| 49 |
+
Set a specific model for internal tasks (title generation, etc.):
|
| 50 |
+
|
| 51 |
+
```ini
|
| 52 |
+
TASK_MODEL=meta-llama/Llama-3.1-8B-Instruct
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
If not set, the current conversation model is used.
|
| 56 |
+
|
| 57 |
+
## Voice Transcription
|
| 58 |
+
|
| 59 |
+
Enable voice input with Whisper:
|
| 60 |
+
|
| 61 |
+
```ini
|
| 62 |
+
TRANSCRIPTION_MODEL=openai/whisper-large-v3-turbo
|
| 63 |
+
TRANSCRIPTION_BASE_URL=https://router.huggingface.co/hf-inference/models
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## Feature Flags
|
| 67 |
+
|
| 68 |
+
```ini
|
| 69 |
+
LLM_SUMMARIZATION=true # Enable automatic conversation title generation
|
| 70 |
+
ENABLE_DATA_EXPORT=true # Allow users to export their data
|
| 71 |
+
ALLOW_IFRAME=false # Disallow embedding in iframes (set to true to allow)
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## User Authentication
|
| 75 |
+
|
| 76 |
+
Use OpenID Connect for authentication:
|
| 77 |
+
|
| 78 |
+
```ini
|
| 79 |
+
OPENID_CLIENT_ID=your_client_id
|
| 80 |
+
OPENID_CLIENT_SECRET=your_client_secret
|
| 81 |
+
OPENID_SCOPES="openid profile"
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
See [OpenID configuration](./open-id) for details.
|
| 85 |
+
|
| 86 |
+
## Environment Variable Reference
|
| 87 |
+
|
| 88 |
+
See the [`.env` file](https://github.com/huggingface/chat-ui/blob/main/.env) for the complete list of available options.
|
docs/source/configuration/theming.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Theming
|
| 2 |
+
|
| 3 |
+
Customize the look and feel of Chat UI with these environment variables:
|
| 4 |
+
|
| 5 |
+
```ini
|
| 6 |
+
PUBLIC_APP_NAME=ChatUI
|
| 7 |
+
PUBLIC_APP_ASSETS=chatui
|
| 8 |
+
PUBLIC_APP_DESCRIPTION="Making the community's best AI chat models available to everyone."
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
- `PUBLIC_APP_NAME` - The name used as a title throughout the app
|
| 12 |
+
- `PUBLIC_APP_ASSETS` - Directory for logos & favicons in `static/$PUBLIC_APP_ASSETS`. Options: `chatui`, `huggingchat`
|
| 13 |
+
- `PUBLIC_APP_DESCRIPTION` - Description shown in meta tags and about sections
|
| 14 |
+
|
| 15 |
+
## Additional Options
|
| 16 |
+
|
| 17 |
+
```ini
|
| 18 |
+
PUBLIC_APP_DATA_SHARING=1 # Show data sharing opt-in toggle in settings
|
| 19 |
+
PUBLIC_ORIGIN=https://chat.example.com # Your public URL (required for sharing)
|
| 20 |
+
```
|
docs/source/developing/architecture.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Architecture
|
| 2 |
+
|
| 3 |
+
This document provides a high-level overview of the Chat UI codebase. If you're looking to contribute or 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 tools via MCP. The project uses [MongoDB](https://www.mongodb.com/) and [SvelteKit](https://kit.svelte.dev/) with [Tailwind](https://tailwindcss.com/).
|
| 8 |
+
|
| 9 |
+
Key architectural decisions:
|
| 10 |
+
- **OpenAI-compatible only**: All model interactions use the OpenAI API format
|
| 11 |
+
- **MCP for tools**: Tool calling is handled via Model Context Protocol servers
|
| 12 |
+
- **Auto-discovery**: Models are discovered from the `/models` endpoint
|
| 13 |
+
|
| 14 |
+
## Code Map
|
| 15 |
+
|
| 16 |
+
### `routes`
|
| 17 |
+
|
| 18 |
+
All routes rendered with SSR via SvelteKit. The majority of backend and frontend logic lives here, with shared modules in `lib` (client) and `lib/server` (server).
|
| 19 |
+
|
| 20 |
+
### `textGeneration`
|
| 21 |
+
|
| 22 |
+
Provides a standard interface for chat features including model output, tool calls, and streaming. Outputs `MessageUpdate`s for fine-grained status updates (new tokens, tool results, etc.).
|
| 23 |
+
|
| 24 |
+
### `endpoints`
|
| 25 |
+
|
| 26 |
+
Provides the streaming interface for OpenAI-compatible endpoints. Models are fetched and cached from `${OPENAI_BASE_URL}/models`.
|
| 27 |
+
|
| 28 |
+
### `mcp`
|
| 29 |
+
|
| 30 |
+
Implements MCP client functionality for tool discovery and execution. See [MCP Tools](../configuration/mcp-tools) for configuration.
|
| 31 |
+
|
| 32 |
+
### `llmRouter`
|
| 33 |
+
|
| 34 |
+
Intelligent routing logic that selects the best model for each request. Uses the Arch router model for classification. See [LLM Router](../configuration/llm-router) for details.
|
| 35 |
+
|
| 36 |
+
### `migrations`
|
| 37 |
+
|
| 38 |
+
MongoDB migrations for maintaining backwards compatibility across schema changes. Any schema changes must include a migration.
|
| 39 |
+
|
| 40 |
+
## Development
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
npm install
|
| 44 |
+
npm run dev
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
The dev server runs at `http://localhost:5173` with hot reloading.
|
docs/source/index.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Chat UI
|
| 2 |
+
|
| 3 |
+
Open source chat interface with support for tools, multimodal inputs, and intelligent routing across models. The app uses MongoDB and SvelteKit behind the scenes. Try the live version called [HuggingChat on hf.co/chat](https://huggingface.co/chat) or [setup your own instance](./installation/local).
|
| 4 |
+
|
| 5 |
+
Chat UI connects to any OpenAI-compatible API endpoint, making it work with:
|
| 6 |
+
- [Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers)
|
| 7 |
+
- [Ollama](https://ollama.ai)
|
| 8 |
+
- [llama.cpp](https://github.com/ggerganov/llama.cpp)
|
| 9 |
+
- [OpenRouter](https://openrouter.ai)
|
| 10 |
+
- Any other OpenAI-compatible service
|
| 11 |
+
|
| 12 |
+
**[MCP Tools](./configuration/mcp-tools)**: Function calling via Model Context Protocol (MCP) servers
|
| 13 |
+
|
| 14 |
+
**[LLM Router](./configuration/llm-router)**: Intelligent routing to select the best model for each request
|
| 15 |
+
|
| 16 |
+
**[Multimodal](./configuration/overview)**: Image uploads on models that support vision
|
| 17 |
+
|
| 18 |
+
**[OpenID](./configuration/open-id)**: Optional user authentication via OpenID Connect
|
| 19 |
+
|
| 20 |
+
## Quickstart
|
| 21 |
+
|
| 22 |
+
**Step 1 - Create `.env.local`:**
|
| 23 |
+
|
| 24 |
+
```ini
|
| 25 |
+
OPENAI_BASE_URL=https://router.huggingface.co/v1
|
| 26 |
+
OPENAI_API_KEY=hf_************************
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
You can use any OpenAI-compatible endpoint:
|
| 30 |
+
|
| 31 |
+
| Provider | `OPENAI_BASE_URL` | `OPENAI_API_KEY` |
|
| 32 |
+
|----------|-------------------|------------------|
|
| 33 |
+
| Hugging Face | `https://router.huggingface.co/v1` | `hf_xxx` |
|
| 34 |
+
| Ollama | `http://127.0.0.1:11434/v1` | `ollama` |
|
| 35 |
+
| llama.cpp | `http://127.0.0.1:8080/v1` | `sk-local` |
|
| 36 |
+
| OpenRouter | `https://openrouter.ai/api/v1` | `sk-or-v1-xxx` |
|
| 37 |
+
|
| 38 |
+
**Step 2 - Install and run:**
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
git clone https://github.com/huggingface/chat-ui
|
| 42 |
+
cd chat-ui
|
| 43 |
+
npm install
|
| 44 |
+
npm run dev -- --open
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
That's it! Chat UI will automatically discover available models from your endpoint.
|
| 48 |
+
|
| 49 |
+
> [!TIP]
|
| 50 |
+
> MongoDB is optional for development. When `MONGODB_URL` is not set, Chat UI uses an embedded database that persists to `./db`.
|
| 51 |
+
|
| 52 |
+
For production deployments, see the [installation guides](./installation/local).
|
docs/source/installation/docker.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Running on Docker
|
| 2 |
+
|
| 3 |
+
Pre-built Docker images are available:
|
| 4 |
+
|
| 5 |
+
- **`ghcr.io/huggingface/chat-ui-db`** - Includes MongoDB (recommended for quick setup)
|
| 6 |
+
- **`ghcr.io/huggingface/chat-ui`** - Requires external MongoDB
|
| 7 |
+
|
| 8 |
+
## Quick Start (with bundled MongoDB)
|
| 9 |
+
|
| 10 |
+
```bash
|
| 11 |
+
docker run -p 3000:3000 \
|
| 12 |
+
-e OPENAI_BASE_URL=https://router.huggingface.co/v1 \
|
| 13 |
+
-e OPENAI_API_KEY=hf_*** \
|
| 14 |
+
-v chat-ui-data:/data \
|
| 15 |
+
ghcr.io/huggingface/chat-ui-db
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
## With External MongoDB
|
| 19 |
+
|
| 20 |
+
If you have an existing MongoDB instance:
|
| 21 |
+
|
| 22 |
+
```bash
|
| 23 |
+
docker run -p 3000:3000 \
|
| 24 |
+
-e OPENAI_BASE_URL=https://router.huggingface.co/v1 \
|
| 25 |
+
-e OPENAI_API_KEY=hf_*** \
|
| 26 |
+
-e MONGODB_URL=mongodb://host.docker.internal:27017 \
|
| 27 |
+
ghcr.io/huggingface/chat-ui
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
Use `host.docker.internal` to reach MongoDB running on your host machine, or provide your MongoDB Atlas connection string.
|
| 31 |
+
|
| 32 |
+
## Using an Environment File
|
| 33 |
+
|
| 34 |
+
For more configuration options, use `--env-file` to avoid leaking secrets in shell history:
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
docker run -p 3000:3000 \
|
| 38 |
+
--env-file .env.local \
|
| 39 |
+
-v chat-ui-data:/data \
|
| 40 |
+
ghcr.io/huggingface/chat-ui-db
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
See the [configuration overview](../configuration/overview) for all available environment variables.
|
docs/source/installation/helm.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Helm
|
| 2 |
+
|
| 3 |
+
<Tip warning={true}>
|
| 4 |
+
|
| 5 |
+
The Helm chart is a work in progress and should be considered unstable. Breaking changes may be pushed without migration guides. Contributions welcome!
|
| 6 |
+
|
| 7 |
+
</Tip>
|
| 8 |
+
|
| 9 |
+
For Kubernetes deployment, use the Helm chart in `/chart`. No chart repository is published, so clone the repository and install by path.
|
| 10 |
+
|
| 11 |
+
## Installation
|
| 12 |
+
|
| 13 |
+
```bash
|
| 14 |
+
git clone https://github.com/huggingface/chat-ui
|
| 15 |
+
cd chat-ui
|
| 16 |
+
helm install chat-ui ./chart -f values.yaml
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
## Example values.yaml
|
| 20 |
+
|
| 21 |
+
```yaml
|
| 22 |
+
replicas: 1
|
| 23 |
+
|
| 24 |
+
domain: example.com
|
| 25 |
+
|
| 26 |
+
service:
|
| 27 |
+
type: ClusterIP
|
| 28 |
+
|
| 29 |
+
resources:
|
| 30 |
+
requests:
|
| 31 |
+
cpu: 100m
|
| 32 |
+
memory: 2Gi
|
| 33 |
+
limits:
|
| 34 |
+
cpu: "4"
|
| 35 |
+
memory: 6Gi
|
| 36 |
+
|
| 37 |
+
envVars:
|
| 38 |
+
OPENAI_BASE_URL: https://router.huggingface.co/v1
|
| 39 |
+
OPENAI_API_KEY: hf_***
|
| 40 |
+
MONGODB_URL: mongodb://chat-ui-mongo:27017
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
See the [configuration overview](../configuration/overview) for all available environment variables.
|
docs/source/installation/local.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Running Locally
|
| 2 |
+
|
| 3 |
+
## Quick Start
|
| 4 |
+
|
| 5 |
+
1. Create a `.env.local` file with your API credentials:
|
| 6 |
+
|
| 7 |
+
```ini
|
| 8 |
+
OPENAI_BASE_URL=https://router.huggingface.co/v1
|
| 9 |
+
OPENAI_API_KEY=hf_************************
|
| 10 |
+
```
|
| 11 |
+
|
| 12 |
+
2. Install and run:
|
| 13 |
+
|
| 14 |
+
```bash
|
| 15 |
+
npm install
|
| 16 |
+
npm run dev -- --open
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
That's it! Chat UI will discover available models automatically from your endpoint.
|
| 20 |
+
|
| 21 |
+
## Configuration
|
| 22 |
+
|
| 23 |
+
Chat UI connects to any OpenAI-compatible API. Set `OPENAI_BASE_URL` to your provider:
|
| 24 |
+
|
| 25 |
+
| Provider | `OPENAI_BASE_URL` |
|
| 26 |
+
|----------|-------------------|
|
| 27 |
+
| Hugging Face | `https://router.huggingface.co/v1` |
|
| 28 |
+
| Ollama | `http://127.0.0.1:11434/v1` |
|
| 29 |
+
| llama.cpp | `http://127.0.0.1:8080/v1` |
|
| 30 |
+
| OpenRouter | `https://openrouter.ai/api/v1` |
|
| 31 |
+
|
| 32 |
+
See the [configuration overview](../configuration/overview) for all available options.
|
| 33 |
+
|
| 34 |
+
## Database
|
| 35 |
+
|
| 36 |
+
For **development**, MongoDB is optional. When `MONGODB_URL` is not set, Chat UI uses an embedded MongoDB server that persists data to the `./db` folder.
|
| 37 |
+
|
| 38 |
+
For **production**, you should use a dedicated MongoDB instance:
|
| 39 |
+
|
| 40 |
+
### Option 1: Local MongoDB (Docker)
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
docker run -d -p 27017:27017 -v mongo-chat-ui:/data --name mongo-chat-ui mongo:latest
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
Then set `MONGODB_URL=mongodb://localhost:27017` in `.env.local`.
|
| 47 |
+
|
| 48 |
+
### Option 2: MongoDB Atlas (Managed)
|
| 49 |
+
|
| 50 |
+
Use [MongoDB Atlas free tier](https://www.mongodb.com/pricing) for a managed database. Copy the connection string to `MONGODB_URL`.
|
| 51 |
+
|
| 52 |
+
## Running in Production
|
| 53 |
+
|
| 54 |
+
For production deployments:
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
npm install
|
| 58 |
+
npm run build
|
| 59 |
+
npm run preview
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
The server listens on `http://localhost:4173` by default.
|