@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.
Files changed (233) hide show
  1. package/README.md +28 -15
  2. package/cli/server.js +72 -14
  3. package/dist/_app/immutable/assets/0.B8jAyHFu.css +2 -0
  4. package/dist/_app/immutable/assets/app.BU-NzFXm.css +1 -0
  5. package/dist/_app/immutable/assets/nerdamer.Cl-GVG6T.js +24 -0
  6. package/dist/_app/immutable/assets/pdf.worker.min.DbR_HJhJ.mjs +29 -0
  7. package/dist/_app/immutable/chunks/1CIrbR2Q.js +1 -0
  8. package/dist/_app/immutable/chunks/1l-8ymtB.js +1 -0
  9. package/dist/_app/immutable/chunks/26Y1-4rB.js +1 -0
  10. package/dist/_app/immutable/chunks/3SQ5KT5a.js +2 -0
  11. package/dist/_app/immutable/chunks/3ymKbqSp.js +1 -0
  12. package/dist/_app/immutable/chunks/531-IPPG.js +1 -0
  13. package/dist/_app/immutable/chunks/5I1j5qRd.js +1 -0
  14. package/dist/_app/immutable/chunks/5k5YNuRS.js +2 -0
  15. package/dist/_app/immutable/chunks/73P-F8U9.js +1 -0
  16. package/dist/_app/immutable/chunks/73lFXAp6.js +1 -0
  17. package/dist/_app/immutable/chunks/8u8Pml-P.js +1 -0
  18. package/dist/_app/immutable/chunks/B-P1Uyq8.js +1 -0
  19. package/dist/_app/immutable/chunks/B-PCS5zA.js +1 -0
  20. package/dist/_app/immutable/chunks/B1CroMsf.js +1 -0
  21. package/dist/_app/immutable/chunks/B1F_0bnw.js +1 -0
  22. package/dist/_app/immutable/chunks/B1pH5dXO.js +1 -0
  23. package/dist/_app/immutable/chunks/B2IDuH-V.js +1 -0
  24. package/dist/_app/immutable/chunks/B3koHNzP.js +1 -0
  25. package/dist/_app/immutable/chunks/B4bepPhE.js +1 -0
  26. package/dist/_app/immutable/chunks/BCEr2jAI.js +1 -0
  27. package/dist/_app/immutable/chunks/BCRbq8jp.js +1 -0
  28. package/dist/_app/immutable/chunks/BD9AMQkN.js +1 -0
  29. package/dist/_app/immutable/chunks/BECLvyNb.js +1 -0
  30. package/dist/_app/immutable/chunks/BGBfXPIx.js +1 -0
  31. package/dist/_app/immutable/chunks/BGRQnnF2.js +1 -0
  32. package/dist/_app/immutable/chunks/BGfA2oQG.js +1 -0
  33. package/dist/_app/immutable/chunks/BHHhacaR.js +1 -0
  34. package/dist/_app/immutable/chunks/BI2r-hyN.js +1 -0
  35. package/dist/_app/immutable/chunks/BJ2OcN8V.js +1 -0
  36. package/dist/_app/immutable/chunks/BLbzjUaV.js +1 -0
  37. package/dist/_app/immutable/chunks/BMhS-uq9.js +1 -0
  38. package/dist/_app/immutable/chunks/BNjRHcgO.js +1 -0
  39. package/dist/_app/immutable/chunks/BOkolQqs.js +1 -0
  40. package/dist/_app/immutable/chunks/BQvSqJrQ.js +1 -0
  41. package/dist/_app/immutable/chunks/BSf_7YOu.js +1 -0
  42. package/dist/_app/immutable/chunks/BUe16zE4.js +1 -0
  43. package/dist/_app/immutable/chunks/BW462adD.js +1 -0
  44. package/dist/_app/immutable/chunks/BWVYCPTK.js +1 -0
  45. package/dist/_app/immutable/chunks/BWaJ3C7D.js +1 -0
  46. package/dist/_app/immutable/chunks/BX-o3EIz.js +1 -0
  47. package/dist/_app/immutable/chunks/BXgVOBG5.js +1 -0
  48. package/dist/_app/immutable/chunks/BaXwJpWq.js +1 -0
  49. package/dist/_app/immutable/chunks/BahAjTwm.js +1 -0
  50. package/dist/_app/immutable/chunks/BakFZ2ml.js +3 -0
  51. package/dist/_app/immutable/chunks/BcBB30ub.js +1 -0
  52. package/dist/_app/immutable/chunks/BiMsFFN_.js +1 -0
  53. package/dist/_app/immutable/chunks/BjYI8dhz.js +1 -0
  54. package/dist/_app/immutable/chunks/Bjg1FiVd.js +1 -0
  55. package/dist/_app/immutable/chunks/Bjy-W4x2.js +81 -0
  56. package/dist/_app/immutable/chunks/BkW-mzl-.js +1 -0
  57. package/dist/_app/immutable/chunks/BmerogBf.js +1 -0
  58. package/dist/_app/immutable/chunks/Boj4HSji.js +1 -0
  59. package/dist/_app/immutable/chunks/BpsPHbGc.js +1 -0
  60. package/dist/_app/immutable/chunks/Bqj0DVIt.js +1 -0
  61. package/dist/_app/immutable/chunks/BqpFWvKu.js +1 -0
  62. package/dist/_app/immutable/chunks/BsbfJrTt.js +1 -0
  63. package/dist/_app/immutable/chunks/BzWcX1gm.js +1 -0
  64. package/dist/_app/immutable/chunks/C0zufGsU.js +1 -0
  65. package/dist/_app/immutable/chunks/C3EegiWg.js +1 -0
  66. package/dist/_app/immutable/chunks/C5TQXDMb.js +1 -0
  67. package/dist/_app/immutable/chunks/C8bVcNXx.js +1 -0
  68. package/dist/_app/immutable/chunks/C9Z__FYS.js +1 -0
  69. package/dist/_app/immutable/chunks/C9lP4FWY.js +1 -0
  70. package/dist/_app/immutable/chunks/CA93Z2eM.js +1 -0
  71. package/dist/_app/immutable/chunks/CBFuTPWj.js +1 -0
  72. package/dist/_app/immutable/chunks/CDc1Vb3D.js +1 -0
  73. package/dist/_app/immutable/chunks/CEFdYGQ4.js +1 -0
  74. package/dist/_app/immutable/chunks/CElFSg8P.js +1 -0
  75. package/dist/_app/immutable/chunks/CHTJ6C4a.js +1 -0
  76. package/dist/_app/immutable/chunks/CJ1TLoQF.js +1 -0
  77. package/dist/_app/immutable/chunks/CJH3ep_3.js +1 -0
  78. package/dist/_app/immutable/chunks/CJb8JxGC.js +1 -0
  79. package/dist/_app/immutable/chunks/CP1rWjpH.js +1 -0
  80. package/dist/_app/immutable/chunks/CPLFVNxS.js +1 -0
  81. package/dist/_app/immutable/chunks/CR1Ogma7.js +1 -0
  82. package/dist/_app/immutable/chunks/CR3yefiA.js +1 -0
  83. package/dist/_app/immutable/chunks/CR7dvLJ4.js +1 -0
  84. package/dist/_app/immutable/chunks/CR9tZ93c.js +1 -0
  85. package/dist/_app/immutable/chunks/CRcZGluc.js +1 -0
  86. package/dist/_app/immutable/chunks/CSRnPoYO.js +1 -0
  87. package/dist/_app/immutable/chunks/CSrFSEx0.js +1 -0
  88. package/dist/_app/immutable/chunks/CVYb4e6m.js +1 -0
  89. package/dist/_app/immutable/chunks/CWGByNpv.js +1 -0
  90. package/dist/_app/immutable/chunks/CXP1cmYR.js +11 -0
  91. package/dist/_app/immutable/chunks/CXnZM-Nf.js +1 -0
  92. package/dist/_app/immutable/chunks/C_5_0OWv.js +1 -0
  93. package/dist/_app/immutable/chunks/C_EjVcnO.js +1 -0
  94. package/dist/_app/immutable/chunks/C_UcIgej.js +1 -0
  95. package/dist/_app/immutable/chunks/C_mGJ3Jy.js +1 -0
  96. package/dist/_app/immutable/chunks/CaM3tfvi.js +1 -0
  97. package/dist/_app/immutable/chunks/CaU6e6N4.js +1 -0
  98. package/dist/_app/immutable/chunks/Cb2OgvrR.js +1 -0
  99. package/dist/_app/immutable/chunks/CcGrHbps.js +3 -0
  100. package/dist/_app/immutable/chunks/Cgnqi5KA.js +1 -0
  101. package/dist/_app/immutable/chunks/CiO3JXx7.js +1 -0
  102. package/dist/_app/immutable/chunks/CjhsRFLe.js +1 -0
  103. package/dist/_app/immutable/chunks/CkSV9Luo.js +1 -0
  104. package/dist/_app/immutable/chunks/ClNaFHRt.js +1 -0
  105. package/dist/_app/immutable/chunks/CpIe18ku.js +1 -0
  106. package/dist/_app/immutable/chunks/CpMp0mBm.js +1 -0
  107. package/dist/_app/immutable/chunks/CpiLaDrO.js +1 -0
  108. package/dist/_app/immutable/chunks/CsXD8KHm.js +411 -0
  109. package/dist/_app/immutable/chunks/Cu9sx8W2.js +1 -0
  110. package/dist/_app/immutable/chunks/CvqMZYuf.js +1 -0
  111. package/dist/_app/immutable/chunks/CxTKDHeA.js +1 -0
  112. package/dist/_app/immutable/chunks/D-4KA1m9.js +1 -0
  113. package/dist/_app/immutable/chunks/D3oKByup.js +1 -0
  114. package/dist/_app/immutable/chunks/D463B8d-.js +1 -0
  115. package/dist/_app/immutable/chunks/D5D75dXm.js +1 -0
  116. package/dist/_app/immutable/chunks/D5l_8KUR.js +1 -0
  117. package/dist/_app/immutable/chunks/D5uGO-jm.js +1 -0
  118. package/dist/_app/immutable/chunks/D6zc0cUO.js +1 -0
  119. package/dist/_app/immutable/chunks/D8SR3GGH.js +1 -0
  120. package/dist/_app/immutable/chunks/DC-R59BF.js +1 -0
  121. package/dist/_app/immutable/chunks/DEWZKVv3.js +1 -0
  122. package/dist/_app/immutable/chunks/DEdPwm2c.js +1 -0
  123. package/dist/_app/immutable/chunks/DGOW1qT8.js +1 -0
  124. package/dist/_app/immutable/chunks/DGokiC3s.js +1 -0
  125. package/dist/_app/immutable/chunks/DGs-X5Vp.js +1 -0
  126. package/dist/_app/immutable/chunks/DJFrA4nv.js +1 -0
  127. package/dist/_app/immutable/chunks/DJqXWVRL.js +1 -0
  128. package/dist/_app/immutable/chunks/DLXDdhyK.js +1 -0
  129. package/dist/_app/immutable/chunks/DMzbk8qN.js +1 -0
  130. package/dist/_app/immutable/chunks/DNWPCnjT.js +1 -0
  131. package/dist/_app/immutable/chunks/DO8eeo3I.js +1 -0
  132. package/dist/_app/immutable/chunks/DOTrSD3H.js +1 -0
  133. package/dist/_app/immutable/chunks/DQKGwi3G.js +1 -0
  134. package/dist/_app/immutable/chunks/DRbqW1u4.js +1 -0
  135. package/dist/_app/immutable/chunks/DS4EA3dC.js +1 -0
  136. package/dist/_app/immutable/chunks/DSQwiuj1.js +1 -0
  137. package/dist/_app/immutable/chunks/DTzUSEH8.js +1 -0
  138. package/dist/_app/immutable/chunks/DV7smCjo.js +3 -0
  139. package/dist/_app/immutable/chunks/DVi5cKOT.js +1 -0
  140. package/dist/_app/immutable/chunks/DWRKyvJ-.js +1 -0
  141. package/dist/_app/immutable/chunks/DZJEcL8n.js +1 -0
  142. package/dist/_app/immutable/chunks/D_ESCULk.js +2 -0
  143. package/dist/_app/immutable/chunks/Da8STgqx.js +1 -0
  144. package/dist/_app/immutable/chunks/DasnpDVC.js +1 -0
  145. package/dist/_app/immutable/chunks/DclECHGd.js +1 -0
  146. package/dist/_app/immutable/chunks/DdjbPXam.js +1 -0
  147. package/dist/_app/immutable/chunks/DeCngaqu.js +1 -0
  148. package/dist/_app/immutable/chunks/Dfm-WMeA.js +1 -0
  149. package/dist/_app/immutable/chunks/Dg6dmf5K.js +1 -0
  150. package/dist/_app/immutable/chunks/Dh71fdD_.js +1 -0
  151. package/dist/_app/immutable/chunks/Dh9PJFmJ.js +1 -0
  152. package/dist/_app/immutable/chunks/DhWmV0s1.js +1 -0
  153. package/dist/_app/immutable/chunks/Dhhcn_CA.js +1 -0
  154. package/dist/_app/immutable/chunks/DjOhhVLG.js +1 -0
  155. package/dist/_app/immutable/chunks/DkTKhn5C.js +1 -0
  156. package/dist/_app/immutable/chunks/DoVWcw3Q.js +1 -0
  157. package/dist/_app/immutable/chunks/DptdJbGO.js +1 -0
  158. package/dist/_app/immutable/chunks/DqHi-6vF.js +1 -0
  159. package/dist/_app/immutable/chunks/Dr9rmg8t.js +1 -0
  160. package/dist/_app/immutable/chunks/Dv0yWYFF.js +1 -0
  161. package/dist/_app/immutable/chunks/DvbP7u24.js +1 -0
  162. package/dist/_app/immutable/chunks/DwUuKi_Q.js +1 -0
  163. package/dist/_app/immutable/chunks/DwhXSSGr.js +1 -0
  164. package/dist/_app/immutable/chunks/Dxj7e8BX.js +1 -0
  165. package/dist/_app/immutable/chunks/Eeu3jWSz.js +4 -0
  166. package/dist/_app/immutable/chunks/F90s6HK_.js +1 -0
  167. package/dist/_app/immutable/chunks/FGVCSpsQ.js +1 -0
  168. package/dist/_app/immutable/chunks/GZmu99Fo.js +1 -0
  169. package/dist/_app/immutable/chunks/Hak9sRVf.js +1 -0
  170. package/dist/_app/immutable/chunks/Hj_vmM07.js +1 -0
  171. package/dist/_app/immutable/chunks/JVA7wRWo.js +1 -0
  172. package/dist/_app/immutable/chunks/KNgW1fZo.js +1 -0
  173. package/dist/_app/immutable/chunks/Ke-GOEW9.js +1 -0
  174. package/dist/_app/immutable/chunks/LZCIum1w.js +1 -0
  175. package/dist/_app/immutable/chunks/NqH9ctA4.js +1 -0
  176. package/dist/_app/immutable/chunks/PZYq2RVY.js +259 -0
  177. package/dist/_app/immutable/chunks/PigSugnL.js +1 -0
  178. package/dist/_app/immutable/chunks/Qa3iLJWP.js +1 -0
  179. package/dist/_app/immutable/chunks/V0F2hNk9.js +1 -0
  180. package/dist/_app/immutable/chunks/Vgr6fxPS.js +1 -0
  181. package/dist/_app/immutable/chunks/Wu2ux-Fn.js +1 -0
  182. package/dist/_app/immutable/chunks/YB8mb-y7.js +1 -0
  183. package/dist/_app/immutable/chunks/YlWmQdSJ.js +1 -0
  184. package/dist/_app/immutable/chunks/YlzcZYWN.js +1 -0
  185. package/dist/_app/immutable/chunks/ZpNubZZ_.js +1 -0
  186. package/dist/_app/immutable/chunks/aGu1RaYf.js +1 -0
  187. package/dist/_app/immutable/chunks/aHBM9jLK.js +1 -0
  188. package/dist/_app/immutable/chunks/aZNm1DXx.js +1 -0
  189. package/dist/_app/immutable/chunks/bShcHfOZ.js +1 -0
  190. package/dist/_app/immutable/chunks/bYSlyn-W.js +1 -0
  191. package/dist/_app/immutable/chunks/cD8rF-Vw.js +1 -0
  192. package/dist/_app/immutable/chunks/dTiwAriW.js +1 -0
  193. package/dist/_app/immutable/chunks/hBR4I1od.js +1 -0
  194. package/dist/_app/immutable/chunks/hKzGh-52.js +1 -0
  195. package/dist/_app/immutable/chunks/iLCLl-5n.js +1 -0
  196. package/dist/_app/immutable/chunks/ifxXhTOO.js +1 -0
  197. package/dist/_app/immutable/chunks/jK6vAkqq.js +1 -0
  198. package/dist/_app/immutable/chunks/lM-YLvZH.js +1 -0
  199. package/dist/_app/immutable/chunks/nSe0mzJm.js +1 -0
  200. package/dist/_app/immutable/chunks/oUUdvLrs.js +1 -0
  201. package/dist/_app/immutable/chunks/p0dfWXuO.js +1 -0
  202. package/dist/_app/immutable/chunks/p0pDTEuW.js +1 -0
  203. package/dist/_app/immutable/chunks/p7Fa3A78.js +1 -0
  204. package/dist/_app/immutable/chunks/qGz9CBa_.js +1 -0
  205. package/dist/_app/immutable/chunks/rqf_V7Lc.js +1 -0
  206. package/dist/_app/immutable/chunks/tFw2_zZo.js +150 -0
  207. package/dist/_app/immutable/chunks/tYyfRjr6.js +1 -0
  208. package/dist/_app/immutable/chunks/tnVFwE0j.js +1 -0
  209. package/dist/_app/immutable/chunks/tuAJdZsI.js +1 -0
  210. package/dist/_app/immutable/chunks/upDuL0ca.js +1 -0
  211. package/dist/_app/immutable/chunks/wv2tBZQi.js +1 -0
  212. package/dist/_app/immutable/chunks/xylFSQAW.js +1 -0
  213. package/dist/_app/immutable/chunks/zdpkyKaR.js +1 -0
  214. package/dist/_app/immutable/entry/app.CJeUTekO.js +2 -0
  215. package/dist/_app/immutable/entry/payload.DSmR2FwN.js +1 -0
  216. package/dist/_app/immutable/entry/start.w7WNk0if.js +2 -0
  217. package/dist/_app/immutable/nodes/0.ByEG0zmr.js +1 -0
  218. package/dist/_app/immutable/nodes/1.BkvpGVa6.js +1 -0
  219. package/dist/_app/immutable/nodes/2.D57n0Bjk.js +1 -0
  220. package/dist/_app/immutable/nodes/3.CVWu7-If.js +1 -0
  221. package/dist/_app/immutable/nodes/4.CW-xYf3I.js +1 -0
  222. package/dist/_app/immutable/nodes/5.C1B-poWf.js +1 -0
  223. package/dist/_app/immutable/nodes/6.CXZYjXfl.js +1 -0
  224. package/dist/_app/immutable/nodes/7.1WeECGN4.js +1 -0
  225. package/dist/_app/version.json +1 -1
  226. package/dist/build.json +1 -1
  227. package/dist/config.json +1 -0
  228. package/dist/index.html +20 -6
  229. package/dist/manifest.webmanifest +1 -1
  230. package/dist/service-worker.js +1 -1
  231. package/package.json +7 -6
  232. package/dist/_app/immutable/assets/bundle.DL4TcXwg.css +0 -2
  233. 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 # serve it on http://127.0.0.1:3000 and open the browser
23
- npx llama-chat --host 0.0.0.0 --no-open # the same, by its short name, reachable from other devices
24
- npx llama-chat build # write the static app to ./llama-chat instead
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 each llama-server you add in the app by URL 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
+ 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, if there is one (llama-server serves it with `--path`, or your reverse proxy puts the API next to the files), and any other llama-server you add by URL, which needs `--cors-origins` for the app's address.
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
- | Hooks | `src/lib/hooks` | View logic between components and stores: scroll, drag and drop, pickers, keyboard |
93
- | Stores | `src/lib/stores` | Application state as Svelte 5 runes: chat, conversations, the agentic loop, tools, models, settings |
94
- | Services | `src/lib/services` | Stateless I/O: the llama-server API, IndexedDB, MCP, the Hugging Face Hub, the tool sandbox |
95
- | Storage + API | the browser, llama-server | IndexedDB and localStorage; llama-server's `/v1`, `/props`, `/models`, `/tools`, `/slots` |
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: start
72
- it with --cors-origins set to this page's address when it restricts origins.
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 HTTP server: the files of `dist`, read-only.
228
- * @param {{ distDir?: string }} [options]
253
+ * The app's config.json for a llama-server at `server`.
254
+ * @param {string} server
229
255
  */
230
- export function createChatServer({ distDir = DIST_DIR } = {}) {
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
- * @param {{ distDir?: string, force?: boolean, out: string }} options
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({ force: options.force, out: options.out });
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
  );