@ggml-org/llama-chat 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -15
- package/cli/server.js +72 -14
- package/dist/_app/immutable/assets/0.B8jAyHFu.css +2 -0
- package/dist/_app/immutable/assets/app.BU-NzFXm.css +1 -0
- package/dist/_app/immutable/assets/nerdamer.Cl-GVG6T.js +24 -0
- package/dist/_app/immutable/assets/pdf.worker.min.DbR_HJhJ.mjs +29 -0
- package/dist/_app/immutable/chunks/1CIrbR2Q.js +1 -0
- package/dist/_app/immutable/chunks/1l-8ymtB.js +1 -0
- package/dist/_app/immutable/chunks/26Y1-4rB.js +1 -0
- package/dist/_app/immutable/chunks/3SQ5KT5a.js +2 -0
- package/dist/_app/immutable/chunks/3ymKbqSp.js +1 -0
- package/dist/_app/immutable/chunks/531-IPPG.js +1 -0
- package/dist/_app/immutable/chunks/5I1j5qRd.js +1 -0
- package/dist/_app/immutable/chunks/5k5YNuRS.js +2 -0
- package/dist/_app/immutable/chunks/73P-F8U9.js +1 -0
- package/dist/_app/immutable/chunks/73lFXAp6.js +1 -0
- package/dist/_app/immutable/chunks/8u8Pml-P.js +1 -0
- package/dist/_app/immutable/chunks/B-P1Uyq8.js +1 -0
- package/dist/_app/immutable/chunks/B-PCS5zA.js +1 -0
- package/dist/_app/immutable/chunks/B1CroMsf.js +1 -0
- package/dist/_app/immutable/chunks/B1F_0bnw.js +1 -0
- package/dist/_app/immutable/chunks/B1pH5dXO.js +1 -0
- package/dist/_app/immutable/chunks/B2IDuH-V.js +1 -0
- package/dist/_app/immutable/chunks/B3koHNzP.js +1 -0
- package/dist/_app/immutable/chunks/B4bepPhE.js +1 -0
- package/dist/_app/immutable/chunks/BCEr2jAI.js +1 -0
- package/dist/_app/immutable/chunks/BCRbq8jp.js +1 -0
- package/dist/_app/immutable/chunks/BD9AMQkN.js +1 -0
- package/dist/_app/immutable/chunks/BECLvyNb.js +1 -0
- package/dist/_app/immutable/chunks/BGBfXPIx.js +1 -0
- package/dist/_app/immutable/chunks/BGRQnnF2.js +1 -0
- package/dist/_app/immutable/chunks/BGfA2oQG.js +1 -0
- package/dist/_app/immutable/chunks/BHHhacaR.js +1 -0
- package/dist/_app/immutable/chunks/BI2r-hyN.js +1 -0
- package/dist/_app/immutable/chunks/BJ2OcN8V.js +1 -0
- package/dist/_app/immutable/chunks/BLbzjUaV.js +1 -0
- package/dist/_app/immutable/chunks/BMhS-uq9.js +1 -0
- package/dist/_app/immutable/chunks/BNjRHcgO.js +1 -0
- package/dist/_app/immutable/chunks/BOkolQqs.js +1 -0
- package/dist/_app/immutable/chunks/BQvSqJrQ.js +1 -0
- package/dist/_app/immutable/chunks/BSf_7YOu.js +1 -0
- package/dist/_app/immutable/chunks/BUe16zE4.js +1 -0
- package/dist/_app/immutable/chunks/BW462adD.js +1 -0
- package/dist/_app/immutable/chunks/BWVYCPTK.js +1 -0
- package/dist/_app/immutable/chunks/BWaJ3C7D.js +1 -0
- package/dist/_app/immutable/chunks/BX-o3EIz.js +1 -0
- package/dist/_app/immutable/chunks/BXgVOBG5.js +1 -0
- package/dist/_app/immutable/chunks/BaXwJpWq.js +1 -0
- package/dist/_app/immutable/chunks/BahAjTwm.js +1 -0
- package/dist/_app/immutable/chunks/BakFZ2ml.js +3 -0
- package/dist/_app/immutable/chunks/BcBB30ub.js +1 -0
- package/dist/_app/immutable/chunks/BiMsFFN_.js +1 -0
- package/dist/_app/immutable/chunks/BjYI8dhz.js +1 -0
- package/dist/_app/immutable/chunks/Bjg1FiVd.js +1 -0
- package/dist/_app/immutable/chunks/Bjy-W4x2.js +81 -0
- package/dist/_app/immutable/chunks/BkW-mzl-.js +1 -0
- package/dist/_app/immutable/chunks/BmerogBf.js +1 -0
- package/dist/_app/immutable/chunks/Boj4HSji.js +1 -0
- package/dist/_app/immutable/chunks/BpsPHbGc.js +1 -0
- package/dist/_app/immutable/chunks/Bqj0DVIt.js +1 -0
- package/dist/_app/immutable/chunks/BqpFWvKu.js +1 -0
- package/dist/_app/immutable/chunks/BsbfJrTt.js +1 -0
- package/dist/_app/immutable/chunks/BzWcX1gm.js +1 -0
- package/dist/_app/immutable/chunks/C0zufGsU.js +1 -0
- package/dist/_app/immutable/chunks/C3EegiWg.js +1 -0
- package/dist/_app/immutable/chunks/C5TQXDMb.js +1 -0
- package/dist/_app/immutable/chunks/C8bVcNXx.js +1 -0
- package/dist/_app/immutable/chunks/C9Z__FYS.js +1 -0
- package/dist/_app/immutable/chunks/C9lP4FWY.js +1 -0
- package/dist/_app/immutable/chunks/CA93Z2eM.js +1 -0
- package/dist/_app/immutable/chunks/CBFuTPWj.js +1 -0
- package/dist/_app/immutable/chunks/CDc1Vb3D.js +1 -0
- package/dist/_app/immutable/chunks/CEFdYGQ4.js +1 -0
- package/dist/_app/immutable/chunks/CElFSg8P.js +1 -0
- package/dist/_app/immutable/chunks/CHTJ6C4a.js +1 -0
- package/dist/_app/immutable/chunks/CJ1TLoQF.js +1 -0
- package/dist/_app/immutable/chunks/CJH3ep_3.js +1 -0
- package/dist/_app/immutable/chunks/CJb8JxGC.js +1 -0
- package/dist/_app/immutable/chunks/CP1rWjpH.js +1 -0
- package/dist/_app/immutable/chunks/CPLFVNxS.js +1 -0
- package/dist/_app/immutable/chunks/CR1Ogma7.js +1 -0
- package/dist/_app/immutable/chunks/CR3yefiA.js +1 -0
- package/dist/_app/immutable/chunks/CR7dvLJ4.js +1 -0
- package/dist/_app/immutable/chunks/CR9tZ93c.js +1 -0
- package/dist/_app/immutable/chunks/CRcZGluc.js +1 -0
- package/dist/_app/immutable/chunks/CSRnPoYO.js +1 -0
- package/dist/_app/immutable/chunks/CSrFSEx0.js +1 -0
- package/dist/_app/immutable/chunks/CVYb4e6m.js +1 -0
- package/dist/_app/immutable/chunks/CWGByNpv.js +1 -0
- package/dist/_app/immutable/chunks/CXP1cmYR.js +11 -0
- package/dist/_app/immutable/chunks/CXnZM-Nf.js +1 -0
- package/dist/_app/immutable/chunks/C_5_0OWv.js +1 -0
- package/dist/_app/immutable/chunks/C_EjVcnO.js +1 -0
- package/dist/_app/immutable/chunks/C_UcIgej.js +1 -0
- package/dist/_app/immutable/chunks/C_mGJ3Jy.js +1 -0
- package/dist/_app/immutable/chunks/CaM3tfvi.js +1 -0
- package/dist/_app/immutable/chunks/CaU6e6N4.js +1 -0
- package/dist/_app/immutable/chunks/Cb2OgvrR.js +1 -0
- package/dist/_app/immutable/chunks/CcGrHbps.js +3 -0
- package/dist/_app/immutable/chunks/Cgnqi5KA.js +1 -0
- package/dist/_app/immutable/chunks/CiO3JXx7.js +1 -0
- package/dist/_app/immutable/chunks/CjhsRFLe.js +1 -0
- package/dist/_app/immutable/chunks/CkSV9Luo.js +1 -0
- package/dist/_app/immutable/chunks/ClNaFHRt.js +1 -0
- package/dist/_app/immutable/chunks/CpIe18ku.js +1 -0
- package/dist/_app/immutable/chunks/CpMp0mBm.js +1 -0
- package/dist/_app/immutable/chunks/CpiLaDrO.js +1 -0
- package/dist/_app/immutable/chunks/CsXD8KHm.js +411 -0
- package/dist/_app/immutable/chunks/Cu9sx8W2.js +1 -0
- package/dist/_app/immutable/chunks/CvqMZYuf.js +1 -0
- package/dist/_app/immutable/chunks/CxTKDHeA.js +1 -0
- package/dist/_app/immutable/chunks/D-4KA1m9.js +1 -0
- package/dist/_app/immutable/chunks/D3oKByup.js +1 -0
- package/dist/_app/immutable/chunks/D463B8d-.js +1 -0
- package/dist/_app/immutable/chunks/D5D75dXm.js +1 -0
- package/dist/_app/immutable/chunks/D5l_8KUR.js +1 -0
- package/dist/_app/immutable/chunks/D5uGO-jm.js +1 -0
- package/dist/_app/immutable/chunks/D6zc0cUO.js +1 -0
- package/dist/_app/immutable/chunks/D8SR3GGH.js +1 -0
- package/dist/_app/immutable/chunks/DC-R59BF.js +1 -0
- package/dist/_app/immutable/chunks/DEWZKVv3.js +1 -0
- package/dist/_app/immutable/chunks/DEdPwm2c.js +1 -0
- package/dist/_app/immutable/chunks/DGOW1qT8.js +1 -0
- package/dist/_app/immutable/chunks/DGokiC3s.js +1 -0
- package/dist/_app/immutable/chunks/DGs-X5Vp.js +1 -0
- package/dist/_app/immutable/chunks/DJFrA4nv.js +1 -0
- package/dist/_app/immutable/chunks/DJqXWVRL.js +1 -0
- package/dist/_app/immutable/chunks/DLXDdhyK.js +1 -0
- package/dist/_app/immutable/chunks/DMzbk8qN.js +1 -0
- package/dist/_app/immutable/chunks/DNWPCnjT.js +1 -0
- package/dist/_app/immutable/chunks/DO8eeo3I.js +1 -0
- package/dist/_app/immutable/chunks/DOTrSD3H.js +1 -0
- package/dist/_app/immutable/chunks/DQKGwi3G.js +1 -0
- package/dist/_app/immutable/chunks/DRbqW1u4.js +1 -0
- package/dist/_app/immutable/chunks/DS4EA3dC.js +1 -0
- package/dist/_app/immutable/chunks/DSQwiuj1.js +1 -0
- package/dist/_app/immutable/chunks/DTzUSEH8.js +1 -0
- package/dist/_app/immutable/chunks/DV7smCjo.js +3 -0
- package/dist/_app/immutable/chunks/DVi5cKOT.js +1 -0
- package/dist/_app/immutable/chunks/DWRKyvJ-.js +1 -0
- package/dist/_app/immutable/chunks/DZJEcL8n.js +1 -0
- package/dist/_app/immutable/chunks/D_ESCULk.js +2 -0
- package/dist/_app/immutable/chunks/Da8STgqx.js +1 -0
- package/dist/_app/immutable/chunks/DasnpDVC.js +1 -0
- package/dist/_app/immutable/chunks/DclECHGd.js +1 -0
- package/dist/_app/immutable/chunks/DdjbPXam.js +1 -0
- package/dist/_app/immutable/chunks/DeCngaqu.js +1 -0
- package/dist/_app/immutable/chunks/Dfm-WMeA.js +1 -0
- package/dist/_app/immutable/chunks/Dg6dmf5K.js +1 -0
- package/dist/_app/immutable/chunks/Dh71fdD_.js +1 -0
- package/dist/_app/immutable/chunks/Dh9PJFmJ.js +1 -0
- package/dist/_app/immutable/chunks/DhWmV0s1.js +1 -0
- package/dist/_app/immutable/chunks/Dhhcn_CA.js +1 -0
- package/dist/_app/immutable/chunks/DjOhhVLG.js +1 -0
- package/dist/_app/immutable/chunks/DkTKhn5C.js +1 -0
- package/dist/_app/immutable/chunks/DoVWcw3Q.js +1 -0
- package/dist/_app/immutable/chunks/DptdJbGO.js +1 -0
- package/dist/_app/immutable/chunks/DqHi-6vF.js +1 -0
- package/dist/_app/immutable/chunks/Dr9rmg8t.js +1 -0
- package/dist/_app/immutable/chunks/Dv0yWYFF.js +1 -0
- package/dist/_app/immutable/chunks/DvbP7u24.js +1 -0
- package/dist/_app/immutable/chunks/DwUuKi_Q.js +1 -0
- package/dist/_app/immutable/chunks/DwhXSSGr.js +1 -0
- package/dist/_app/immutable/chunks/Dxj7e8BX.js +1 -0
- package/dist/_app/immutable/chunks/Eeu3jWSz.js +4 -0
- package/dist/_app/immutable/chunks/F90s6HK_.js +1 -0
- package/dist/_app/immutable/chunks/FGVCSpsQ.js +1 -0
- package/dist/_app/immutable/chunks/GZmu99Fo.js +1 -0
- package/dist/_app/immutable/chunks/Hak9sRVf.js +1 -0
- package/dist/_app/immutable/chunks/Hj_vmM07.js +1 -0
- package/dist/_app/immutable/chunks/JVA7wRWo.js +1 -0
- package/dist/_app/immutable/chunks/KNgW1fZo.js +1 -0
- package/dist/_app/immutable/chunks/Ke-GOEW9.js +1 -0
- package/dist/_app/immutable/chunks/LZCIum1w.js +1 -0
- package/dist/_app/immutable/chunks/NqH9ctA4.js +1 -0
- package/dist/_app/immutable/chunks/PZYq2RVY.js +259 -0
- package/dist/_app/immutable/chunks/PigSugnL.js +1 -0
- package/dist/_app/immutable/chunks/Qa3iLJWP.js +1 -0
- package/dist/_app/immutable/chunks/V0F2hNk9.js +1 -0
- package/dist/_app/immutable/chunks/Vgr6fxPS.js +1 -0
- package/dist/_app/immutable/chunks/Wu2ux-Fn.js +1 -0
- package/dist/_app/immutable/chunks/YB8mb-y7.js +1 -0
- package/dist/_app/immutable/chunks/YlWmQdSJ.js +1 -0
- package/dist/_app/immutable/chunks/YlzcZYWN.js +1 -0
- package/dist/_app/immutable/chunks/ZpNubZZ_.js +1 -0
- package/dist/_app/immutable/chunks/aGu1RaYf.js +1 -0
- package/dist/_app/immutable/chunks/aHBM9jLK.js +1 -0
- package/dist/_app/immutable/chunks/aZNm1DXx.js +1 -0
- package/dist/_app/immutable/chunks/bShcHfOZ.js +1 -0
- package/dist/_app/immutable/chunks/bYSlyn-W.js +1 -0
- package/dist/_app/immutable/chunks/cD8rF-Vw.js +1 -0
- package/dist/_app/immutable/chunks/dTiwAriW.js +1 -0
- package/dist/_app/immutable/chunks/hBR4I1od.js +1 -0
- package/dist/_app/immutable/chunks/hKzGh-52.js +1 -0
- package/dist/_app/immutable/chunks/iLCLl-5n.js +1 -0
- package/dist/_app/immutable/chunks/ifxXhTOO.js +1 -0
- package/dist/_app/immutable/chunks/jK6vAkqq.js +1 -0
- package/dist/_app/immutable/chunks/lM-YLvZH.js +1 -0
- package/dist/_app/immutable/chunks/nSe0mzJm.js +1 -0
- package/dist/_app/immutable/chunks/oUUdvLrs.js +1 -0
- package/dist/_app/immutable/chunks/p0dfWXuO.js +1 -0
- package/dist/_app/immutable/chunks/p0pDTEuW.js +1 -0
- package/dist/_app/immutable/chunks/p7Fa3A78.js +1 -0
- package/dist/_app/immutable/chunks/qGz9CBa_.js +1 -0
- package/dist/_app/immutable/chunks/rqf_V7Lc.js +1 -0
- package/dist/_app/immutable/chunks/tFw2_zZo.js +150 -0
- package/dist/_app/immutable/chunks/tYyfRjr6.js +1 -0
- package/dist/_app/immutable/chunks/tnVFwE0j.js +1 -0
- package/dist/_app/immutable/chunks/tuAJdZsI.js +1 -0
- package/dist/_app/immutable/chunks/upDuL0ca.js +1 -0
- package/dist/_app/immutable/chunks/wv2tBZQi.js +1 -0
- package/dist/_app/immutable/chunks/xylFSQAW.js +1 -0
- package/dist/_app/immutable/chunks/zdpkyKaR.js +1 -0
- package/dist/_app/immutable/entry/app.CJeUTekO.js +2 -0
- package/dist/_app/immutable/entry/payload.DSmR2FwN.js +1 -0
- package/dist/_app/immutable/entry/start.w7WNk0if.js +2 -0
- package/dist/_app/immutable/nodes/0.ByEG0zmr.js +1 -0
- package/dist/_app/immutable/nodes/1.BkvpGVa6.js +1 -0
- package/dist/_app/immutable/nodes/2.D57n0Bjk.js +1 -0
- package/dist/_app/immutable/nodes/3.CVWu7-If.js +1 -0
- package/dist/_app/immutable/nodes/4.CW-xYf3I.js +1 -0
- package/dist/_app/immutable/nodes/5.C1B-poWf.js +1 -0
- package/dist/_app/immutable/nodes/6.CXZYjXfl.js +1 -0
- package/dist/_app/immutable/nodes/7.1WeECGN4.js +1 -0
- package/dist/_app/version.json +1 -1
- package/dist/build.json +1 -1
- package/dist/config.json +1 -0
- package/dist/index.html +20 -6
- package/dist/manifest.webmanifest +1 -1
- package/dist/service-worker.js +1 -1
- package/package.json +7 -6
- package/dist/_app/immutable/assets/bundle.DL4TcXwg.css +0 -2
- package/dist/_app/immutable/bundle.DIMNEksO.js +0 -4068
package/README.md
CHANGED
|
@@ -19,13 +19,14 @@ It works with a llama-server in either mode: **MODEL** (one model) or **ROUTER**
|
|
|
19
19
|
Llama Chat is published to npm as [`@ggml-org/llama-chat`](https://www.npmjs.com/package/@ggml-org/llama-chat), with [`llama-chat`](https://www.npmjs.com/package/llama-chat) as its short name. It serves the prebuilt app as static files on localhost, or writes them to a folder for any static file server (see [Self-hosting](#self-hosting)); it brings no server and no models of its own. It needs Node.js 20 or later.
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npx @ggml-org/llama-chat
|
|
23
|
-
npx llama-chat --host 0.0.0.0 --no-open
|
|
24
|
-
npx llama-chat build
|
|
22
|
+
npx @ggml-org/llama-chat --server http://localhost:8080 # serve it on http://127.0.0.1:3000 for that llama-server
|
|
23
|
+
npx llama-chat --host 0.0.0.0 --no-open # by its short name, reachable from other devices
|
|
24
|
+
npx llama-chat build # write the static app to ./llama-chat instead
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
| Flag | Default | What it does |
|
|
28
28
|
| --------------------------------- | ----------- | ------------------------------------------------------------------------------------------- |
|
|
29
|
+
| `--server <url>` | | The llama-server the app talks to, e.g. `http://localhost:8080`; also for `build` |
|
|
29
30
|
| `--port <n>` | `3000` | Fixed, so the origin, and the chats the browser stores under it, stay the same between runs |
|
|
30
31
|
| `--host <addr>` | `127.0.0.1` | `0.0.0.0` to open it to the LAN |
|
|
31
32
|
| `--open` / `--no-open` | open | Opens the default browser once it listens |
|
|
@@ -33,13 +34,19 @@ npx llama-chat build # write the static app to ./llama-chat
|
|
|
33
34
|
|
|
34
35
|
The bare command is the documented form; `start` is accepted as an alias for it. `build` takes `--out <dir>` (default `./llama-chat`) and `--force`, which lets it write into a folder that is not empty.
|
|
35
36
|
|
|
36
|
-
How it works: the CLI only serves the files of `dist`, with llama-server's headers for the UI (`index.html` cross-origin isolated, the PWA files revalidated, hashed assets cached for good), and forwards nothing. The browser talks to
|
|
37
|
+
How it works: the CLI only serves the files of `dist`, with llama-server's headers for the UI (`index.html` cross-origin isolated, the PWA files revalidated, hashed assets cached for good), and forwards nothing. The browser talks to the llama-server named with `--server` directly, so llama-server's own rules apply: start it with `--cors-origins http://127.0.0.1:3000` (the address you open) when it restricts origins, as it does with tools or MCP enabled, and with `--api-key` when it is reachable from the LAN. An `http://` page like this one can reach a plain `http://` llama-server on the LAN, which an `https://` page cannot.
|
|
37
38
|
|
|
38
39
|
## Self-hosting
|
|
39
40
|
|
|
40
41
|
The app is static and uses relative paths and a hash router, so any static host can serve it at any path. `npx @ggml-org/llama-chat build --out <dir>` writes the files (as does `npm run build` here, to `dist`); serve them with any static file server, for example `npx http-server llama-chat -p 3000`. Send the headers listed above with `index.html` and the PWA files, so the app behaves as it does under llama-server (see [Cross-origin isolation](#cross-origin-isolation)).
|
|
41
42
|
|
|
42
|
-
The app reaches the llama-server on its own origin
|
|
43
|
+
The app reaches the llama-server on its own origin by default (llama-server serves it with `--path`, or your reverse proxy puts the API next to the files). To host it apart from llama-server, name the server in `config.json`, the file next to `index.html`:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{ "server": "http://localhost:8080" }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`npx llama-chat build --server <url>` writes that file, and `npx llama-chat --server <url>` answers it without one. The app reads it on every start, past its caches, so a host can change it without a new build. That llama-server needs `--cors-origins` for the app's address when it restricts origins.
|
|
43
50
|
|
|
44
51
|
## Features
|
|
45
52
|
|
|
@@ -48,7 +55,7 @@ The app reaches the llama-server on its own origin, if there is one (llama-serve
|
|
|
48
55
|
- **Rendering** - Markdown (GFM), code highlighting, KaTeX math and Mermaid diagrams
|
|
49
56
|
- **Models** - in ROUTER mode, a selector and a models manager: load and unload, downloads, Discover from the Hugging Face Hub, favorites and hidden models
|
|
50
57
|
- **Tools** - built-in browser tools, llama-server's tools and MCP servers, each behind a permission prompt
|
|
51
|
-
- **Everywhere** - light and dark themes, phone layouts, installable as a PWA, keyboard shortcuts (`Ctrl/Cmd+K` search, `Shift+Ctrl/Cmd+O` new chat, `Ctrl/Cmd+B` sidebar)
|
|
58
|
+
- **Everywhere** - light and dark themes, phone layouts, installable as a PWA, keyboard shortcuts (`Ctrl/Cmd+K` search, `Shift+Ctrl/Cmd+O` new chat, `Ctrl/Cmd+B` sidebar, `Esc` stop the reply)
|
|
52
59
|
|
|
53
60
|
## Development
|
|
54
61
|
|
|
@@ -84,15 +91,17 @@ Llama Chat is the first app on Llama UI, and the reference for the line between
|
|
|
84
91
|
|
|
85
92
|
The app imports the library as `@ggml-org/llama-ui/ui/<name>` and compiles its sources in its own build, with no install of the library (see `scripts/vite-plugin-llama-ui.ts`). Data flows one way, through these layers:
|
|
86
93
|
|
|
87
|
-
| Layer | Lives in | What it holds
|
|
88
|
-
| -------------- | ------------------------- |
|
|
89
|
-
| Routes | `src/routes` | `/`, `/chat/[id]`, `/models`, `/mcp-servers`, `/settings`, `/search`
|
|
90
|
-
| App components | `src/lib/components/app` | Chat, navigation, models, MCP, settings and dialogs, grouped by area
|
|
91
|
-
| UI components | `ui/lib/ui` | shadcn-svelte on bits-ui, from Llama UI
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
94
|
+
| Layer | Lives in | What it holds |
|
|
95
|
+
| -------------- | ------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| Routes | `src/routes` | `/`, `/chat/[id]`, `/models`, `/mcp-servers`, `/settings`, `/search` |
|
|
97
|
+
| App components | `src/lib/components/app` | Chat, navigation, models, MCP, settings and dialogs, grouped by area |
|
|
98
|
+
| UI components | `ui/lib/ui` | shadcn-svelte on bits-ui, from Llama UI |
|
|
99
|
+
| Voice | `ui/lib/voice` | Microphone capture, transcription and dictation, from Llama Voice (`@ggml-org/llama-voice`) |
|
|
100
|
+
| Hooks | `src/lib/hooks` | View logic between components and stores: scroll, drag and drop, pickers, keyboard |
|
|
101
|
+
| Stores | `src/lib/stores` | Application state as Svelte 5 runes: chat, conversations, the agentic loop, tools, models, settings |
|
|
102
|
+
| Agentic loop | `ui/lib/harness` | Llama Harness: streams a turn, runs the tools the model called, repeats until it answers without one |
|
|
103
|
+
| Services | `src/lib/services` | Stateless I/O: the llama-server API, IndexedDB, MCP, the Hugging Face Hub, the tool sandbox |
|
|
104
|
+
| Storage + API | the browser, llama-server | IndexedDB and localStorage; llama-server's `/v1`, `/props`, `/models`, `/tools`, `/slots` |
|
|
96
105
|
|
|
97
106
|
```mermaid
|
|
98
107
|
flowchart LR
|
|
@@ -152,6 +161,10 @@ llama-server serves the UI with `Cross-Origin-Embedder-Policy: require-corp` and
|
|
|
152
161
|
|
|
153
162
|
llama-server embeds it: when llama-server is built, `scripts/ui-assets.cmake` takes `ui/apps/chat/dist` if it exists, runs `npm run build` if `LLAMA_BUILD_UI` is on, or downloads the release's prebuilt `dist.tar.gz` from Hugging Face, and compiles every file into the binary. The same `dist` is what `npx @ggml-org/llama-chat` serves.
|
|
154
163
|
|
|
164
|
+
**Plain chat and agent mode.** Llama Chat is a plain chat, a message and its reply with reasoning when the model gives it, unless llama-server offers the agentic features: its built-in tools or its proxy, which `llama-server --agent` turns on together. `llama-server --ui-agent` turns agent mode on with neither: the model gets only the tools that run in the browser, and MCP servers the browser reaches itself. The app reads this from `/props` and `/tools`. With them it shows the tools menu, the working folder, MCP and the Tools and Agentic settings, and runs the agentic loop; without them it shows none of these and sends the classic request. Tool calls in earlier conversations still display.
|
|
165
|
+
|
|
166
|
+
**Chat-only build.** `VITE_PUBLIC_AGENTIC=false npm run build` builds an app that is a plain chat for every server, and `npm run dev:chat-only` runs the dev server the same way. Llama Harness's loop is left out of its bundle.
|
|
167
|
+
|
|
155
168
|
```text
|
|
156
169
|
ui/apps/chat/
|
|
157
170
|
├── src/
|
package/cli/server.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import { spawn } from 'node:child_process';
|
|
13
13
|
import { createReadStream, readFileSync } from 'node:fs';
|
|
14
|
-
import { cp, readdir, stat } from 'node:fs/promises';
|
|
14
|
+
import { cp, readdir, stat, writeFile } from 'node:fs/promises';
|
|
15
15
|
import http from 'node:http';
|
|
16
16
|
import { extname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path';
|
|
17
17
|
import { fileURLToPath } from 'node:url';
|
|
@@ -36,8 +36,11 @@ const NO_CACHE = new Set([
|
|
|
36
36
|
'/sw.js',
|
|
37
37
|
'/manifest.webmanifest',
|
|
38
38
|
'/_app/version.json',
|
|
39
|
-
'/build.json'
|
|
39
|
+
'/build.json',
|
|
40
|
+
'/config.json'
|
|
40
41
|
]);
|
|
42
|
+
// the file next to index.html that tells the app where llama-server is
|
|
43
|
+
const CONFIG_PATH = '/config.json';
|
|
41
44
|
const CACHE_IMMUTABLE = 'public, max-age=31536000, immutable';
|
|
42
45
|
const CACHE_REVALIDATE = 'no-cache';
|
|
43
46
|
/** @type {Record<string, string>} */
|
|
@@ -68,10 +71,13 @@ export const USAGE = `Usage: llama-chat [options]
|
|
|
68
71
|
llama-chat build [--out <dir>] [--force]
|
|
69
72
|
|
|
70
73
|
Serves Llama Chat on localhost as static files, or, with build, writes them to
|
|
71
|
-
a folder for any HTTP server. The browser talks to llama-server directly:
|
|
72
|
-
it with --cors-origins set to this page's address
|
|
74
|
+
a folder for any HTTP server. The browser talks to llama-server directly: name
|
|
75
|
+
it with --server, and start it with --cors-origins set to this page's address
|
|
76
|
+
when it restricts origins.
|
|
73
77
|
|
|
74
78
|
Options:
|
|
79
|
+
--server <url> the llama-server the app talks to, e.g. http://localhost:8080
|
|
80
|
+
(also for build; default: the address the app is served on)
|
|
75
81
|
--port <n> port to listen on (default: ${DEFAULTS.port})
|
|
76
82
|
--host <addr> address to listen on, 0.0.0.0 for the LAN (default: ${DEFAULTS.host})
|
|
77
83
|
--open open the browser once it listens (default)
|
|
@@ -84,9 +90,9 @@ Build options:
|
|
|
84
90
|
--force write into a folder that is not empty
|
|
85
91
|
|
|
86
92
|
Examples:
|
|
87
|
-
npx @ggml-org/llama-chat
|
|
93
|
+
npx @ggml-org/llama-chat --server http://localhost:8080
|
|
88
94
|
npx @ggml-org/llama-chat --host 0.0.0.0 --port 3000 --no-open
|
|
89
|
-
npx @ggml-org/llama-chat build --out ./public`;
|
|
95
|
+
npx @ggml-org/llama-chat build --out ./public --server https://llm.example.com`;
|
|
90
96
|
|
|
91
97
|
/** The version in this package's package.json. */
|
|
92
98
|
export function packageVersion() {
|
|
@@ -97,7 +103,7 @@ export function packageVersion() {
|
|
|
97
103
|
* Reads the command line. No verb serves the app, `start` means the same, and `build` writes it
|
|
98
104
|
* to a folder.
|
|
99
105
|
* @param {string[]} argv the arguments after the command
|
|
100
|
-
* @returns {{ command: 'build' | 'serve', force: boolean, help: boolean, host: string, open: boolean, out: string, port: number, version: boolean }}
|
|
106
|
+
* @returns {{ command: 'build' | 'serve', force: boolean, help: boolean, host: string, open: boolean, out: string, port: number, server: string, version: boolean }}
|
|
101
107
|
*/
|
|
102
108
|
export function parseCliArgs(argv) {
|
|
103
109
|
const { positionals, values } = parseArgs({
|
|
@@ -111,6 +117,7 @@ export function parseCliArgs(argv) {
|
|
|
111
117
|
open: { type: 'boolean' },
|
|
112
118
|
out: { type: 'string' },
|
|
113
119
|
port: { type: 'string' },
|
|
120
|
+
server: { type: 'string' },
|
|
114
121
|
version: { short: 'v', type: 'boolean' }
|
|
115
122
|
},
|
|
116
123
|
strict: true
|
|
@@ -138,6 +145,24 @@ export function parseCliArgs(argv) {
|
|
|
138
145
|
throw new Error(`invalid --port: ${values.port}`);
|
|
139
146
|
}
|
|
140
147
|
|
|
148
|
+
let server = '';
|
|
149
|
+
|
|
150
|
+
if (values.server !== undefined) {
|
|
151
|
+
let parsed;
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
parsed = new URL(values.server);
|
|
155
|
+
} catch {
|
|
156
|
+
parsed = null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (!parsed || (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')) {
|
|
160
|
+
throw new Error(`invalid --server, expected an http(s) URL: ${values.server}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
server = `${parsed.origin}${parsed.pathname.replace(/\/+$/, '')}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
141
166
|
return {
|
|
142
167
|
command,
|
|
143
168
|
force: values.force ?? false,
|
|
@@ -146,6 +171,7 @@ export function parseCliArgs(argv) {
|
|
|
146
171
|
open: values.open ?? true,
|
|
147
172
|
out: values.out ?? DEFAULTS.out,
|
|
148
173
|
port,
|
|
174
|
+
server,
|
|
149
175
|
version: values.version ?? false
|
|
150
176
|
};
|
|
151
177
|
}
|
|
@@ -224,10 +250,19 @@ function sendError(res, status, message) {
|
|
|
224
250
|
}
|
|
225
251
|
|
|
226
252
|
/**
|
|
227
|
-
* The
|
|
228
|
-
* @param {
|
|
253
|
+
* The app's config.json for a llama-server at `server`.
|
|
254
|
+
* @param {string} server
|
|
229
255
|
*/
|
|
230
|
-
|
|
256
|
+
function configJson(server) {
|
|
257
|
+
return `${JSON.stringify({ server })}\n`;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The HTTP server: the files of `dist`, read-only. With `server`, it answers config.json
|
|
262
|
+
* itself, so the app talks to that llama-server instead of this address.
|
|
263
|
+
* @param {{ distDir?: string, server?: string }} [options]
|
|
264
|
+
*/
|
|
265
|
+
export function createChatServer({ distDir = DIST_DIR, server = '' } = {}) {
|
|
231
266
|
const root = normalize(distDir);
|
|
232
267
|
|
|
233
268
|
return http.createServer(async (req, res) => {
|
|
@@ -240,6 +275,19 @@ export function createChatServer({ distDir = DIST_DIR } = {}) {
|
|
|
240
275
|
return;
|
|
241
276
|
}
|
|
242
277
|
|
|
278
|
+
if (server && pathname === CONFIG_PATH) {
|
|
279
|
+
const body = configJson(server);
|
|
280
|
+
|
|
281
|
+
res.writeHead(200, {
|
|
282
|
+
'Cache-Control': CACHE_REVALIDATE,
|
|
283
|
+
'Content-Length': Buffer.byteLength(body),
|
|
284
|
+
'Content-Type': MIME_TYPES['.json']
|
|
285
|
+
});
|
|
286
|
+
res.end(req.method === 'HEAD' ? undefined : body);
|
|
287
|
+
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
243
291
|
const file = resolveStatic(root, pathname);
|
|
244
292
|
const stats = file ? await stat(file).catch(() => null) : null;
|
|
245
293
|
|
|
@@ -256,10 +304,11 @@ export function createChatServer({ distDir = DIST_DIR } = {}) {
|
|
|
256
304
|
/**
|
|
257
305
|
* Writes the app to a folder: the files of `dist` without source maps, ready for any static
|
|
258
306
|
* file server. Refuses a folder that is not empty unless `force` is set, and a folder in `dist`.
|
|
259
|
-
*
|
|
307
|
+
* With `server`, its config.json names that llama-server.
|
|
308
|
+
* @param {{ distDir?: string, force?: boolean, out: string, server?: string }} options
|
|
260
309
|
* @returns {Promise<string>} the absolute path of the folder
|
|
261
310
|
*/
|
|
262
|
-
export async function buildStatic({ distDir = DIST_DIR, force = false, out }) {
|
|
311
|
+
export async function buildStatic({ distDir = DIST_DIR, force = false, out, server = '' }) {
|
|
263
312
|
const source = resolve(distDir);
|
|
264
313
|
const target = resolve(out);
|
|
265
314
|
const inside = relative(source, target);
|
|
@@ -276,6 +325,8 @@ export async function buildStatic({ distDir = DIST_DIR, force = false, out }) {
|
|
|
276
325
|
|
|
277
326
|
await cp(source, target, { filter: (file) => !file.endsWith('.map'), recursive: true });
|
|
278
327
|
|
|
328
|
+
if (server) await writeFile(join(target, CONFIG_PATH), configJson(server));
|
|
329
|
+
|
|
279
330
|
return target;
|
|
280
331
|
}
|
|
281
332
|
|
|
@@ -339,7 +390,11 @@ export async function main(argv) {
|
|
|
339
390
|
|
|
340
391
|
if (options.command === 'build') {
|
|
341
392
|
try {
|
|
342
|
-
const target = await buildStatic({
|
|
393
|
+
const target = await buildStatic({
|
|
394
|
+
force: options.force,
|
|
395
|
+
out: options.out,
|
|
396
|
+
server: options.server
|
|
397
|
+
});
|
|
343
398
|
const shown = relative(process.cwd(), target) || '.';
|
|
344
399
|
|
|
345
400
|
console.log(`Llama Chat ${packageVersion()} written to ${target}`);
|
|
@@ -352,7 +407,7 @@ export async function main(argv) {
|
|
|
352
407
|
return;
|
|
353
408
|
}
|
|
354
409
|
|
|
355
|
-
const server = createChatServer();
|
|
410
|
+
const server = createChatServer({ server: options.server });
|
|
356
411
|
|
|
357
412
|
return new Promise((resolve) => {
|
|
358
413
|
server.on('error', (error) => {
|
|
@@ -373,6 +428,9 @@ export async function main(argv) {
|
|
|
373
428
|
const url = `http://${shown.includes(':') ? `[${shown}]` : shown}:${address.port}/`;
|
|
374
429
|
|
|
375
430
|
console.log(`Llama Chat ${packageVersion()} on ${url}`);
|
|
431
|
+
|
|
432
|
+
if (options.server) console.log(`Talking to llama-server on ${options.server}`);
|
|
433
|
+
|
|
376
434
|
console.log(
|
|
377
435
|
`If llama-server restricts origins (tools or MCP on), start it with --cors-origins ${url.slice(0, -1)}`
|
|
378
436
|
);
|