|
| 1 | +# LLaMA.cpp Web UI |
| 2 | + |
| 3 | +The project includes a web-based user interface that enables interaction with the model through the `/chat/completions` |
| 4 | +endpoint. |
| 5 | + |
| 6 | +**Features:** |
| 7 | + |
| 8 | +- Mobile, medium devices and desktop UI/UX |
| 9 | +- Localisations (Chinese, Deutch, English, French, Italian, Spanish, Russian) |
| 10 | +- Conversation list |
| 11 | + - save / edit / conversations |
| 12 | +- Settings tag |
| 13 | + - Presets |
| 14 | + - automatic if config file embed in server |
| 15 | + - load file (save embed file) |
| 16 | + - multilingual |
| 17 | +- Ideas of questions (loaded with presets) |
| 18 | +- [Experimental] Python interpreter |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +## Prompt master |
| 23 | + |
| 24 | +To quickly make a change in your settings you can go to the Settings tab. |
| 25 | +To make change effective, click the save button in bottom right corner. |
| 26 | + |
| 27 | +### Json presets |
| 28 | + |
| 29 | +If you want to configure some presets, use the json configuration file. |
| 30 | +If you leave language empty, it will show in all languages. |
| 31 | +When loading, the first preset of the list in your language will be used. |
| 32 | +When you change language, presets will be reloaded using the new language. |
| 33 | + |
| 34 | +Here a full example of json presets : |
| 35 | + |
| 36 | +```json |
| 37 | +{ |
| 38 | + "presets": [ |
| 39 | + { |
| 40 | + "name": "Configuration example", |
| 41 | + "lang": "en", |
| 42 | + "config": { |
| 43 | + "apiKey": "", |
| 44 | + "custom": "", |
| 45 | + "dry_allowed_length": 2, |
| 46 | + "dry_base": 1.75, |
| 47 | + "dry_multiplier": 0, |
| 48 | + "dry_penalty_last_n": -1, |
| 49 | + "dynatemp_exponent": 1, |
| 50 | + "dynatemp_range": 0, |
| 51 | + "excludeThoughtOnReq": true, |
| 52 | + "frequency_penalty": 0, |
| 53 | + "max_tokens": -1, |
| 54 | + "min_p": 0.05, |
| 55 | + "presence_penalty": 0, |
| 56 | + "pyIntepreterEnabled": false, |
| 57 | + "repeat_last_n": 64, |
| 58 | + "repeat_penalty": 1, |
| 59 | + "samplers": "edkypmxt", |
| 60 | + "showThoughtInProgress": false, |
| 61 | + "showTokensPerSecond": false, |
| 62 | + "systemMessage": "You are a helpful assistant.", |
| 63 | + "temperature": 0.8, |
| 64 | + "top_k": 40, |
| 65 | + "top_p": 0.95, |
| 66 | + "typical_p": 1, |
| 67 | + "xtc_probability": 0, |
| 68 | + "xtc_threshold": 0.1, |
| 69 | + "questionIdeas": [ |
| 70 | + "Who are you, what can you do?", |
| 71 | + "What to do, what to see, what to visit in Italy?", |
| 72 | + "Write a simple python function that\n1. Ask me for a number in mile\n2. It converts miles to kilometers" |
| 73 | + ] |
| 74 | + } |
| 75 | + }, |
| 76 | + { |
| 77 | + "name": "Python Coder", |
| 78 | + "lang": "", |
| 79 | + "config": { |
| 80 | + "systemMessage": "You are a coder assistant. You will answer returning python code of what the user asked for.", |
| 81 | + "temperature": 0.6, |
| 82 | + "top_k": 20, |
| 83 | + "pyIntepreterEnabled": true, |
| 84 | + "questionIdeas": [ |
| 85 | + "Write a simple python function that\n1. Ask me for a number in mile\n2. It converts miles to kilometers" |
| 86 | + ] |
| 87 | + } |
| 88 | + } |
| 89 | + ] |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +In this example, "Python Coder" will be shown on other languages than English. |
| 94 | +It will use the default configuration (same as example preset just above). |
| 95 | +It will suggest `questionIdeas` when no conversation is loaded. |
| 96 | +All settings parameters you can change are listed in the first preset. |
| 97 | +If a parameter has not the right type, it won't be loaded and will be show a message in the console. |
| 98 | + |
| 99 | +## Development |
| 100 | + |
| 101 | +The web UI is developed using: |
| 102 | + |
| 103 | +- `react` framework for frontend development |
| 104 | +- `tailwindcss` and `daisyui` for styling |
| 105 | +- `vite` for build tooling |
| 106 | + |
| 107 | +A pre-built version is available as a single HTML file under `/public` directory. |
| 108 | + |
| 109 | +To build or to run the dev server (with hot reload): |
| 110 | + |
| 111 | +```sh |
| 112 | +# make sure you have nodejs installed |
| 113 | +cd examples/server/webui |
| 114 | +npm i |
| 115 | + |
| 116 | +# to run the dev server |
| 117 | +npm run dev |
| 118 | + |
| 119 | +# to build the public/index.html.gz |
| 120 | +npm run build |
| 121 | +``` |
| 122 | + |
| 123 | +After `public/index.html.gz` has been generated we need to generate the c++ |
| 124 | +headers (like build/examples/server/index.html.gz.hpp) that will be included |
| 125 | +by server.cpp. This is done by building `llama-server` as described in the |
| 126 | +[llama-server build](../README.md#build) section. |
| 127 | + |
| 128 | +Prompt and other configuration parameters are easily customisable with the json file `public/prompts.config.json` or |
| 129 | +through loading it in the UI. |
| 130 | +If you want to always load a file, you can rename `public/prompts.config.example.json` to `public/prompts.config.json` |
| 131 | +and it will always be loaded at application startup. |
| 132 | + |
| 133 | +Examples from https://github.com/f/awesome-chatgpt-prompts have been already written in it. |
| 134 | + |
| 135 | +NOTE: if you are using the vite dev server, you can change the API base URL to llama.cpp. To do that, run this code |
| 136 | +snippet in browser's console: |
| 137 | + |
| 138 | +```js |
| 139 | +localStorage.setItem('base', 'http://localhost:8080'); |
| 140 | +``` |
| 141 | + |
| 142 | +The project is under active development, and we |
| 143 | +are [looking for feedback and contributors](https://github.com/ggml-org/llama.cpp/issues/4216). |
| 144 | + |
| 145 | +## Screenshoots |
| 146 | + |
| 147 | +### Desktop / Theme |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | +### Medium devices |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | +### Mobile / UI / Translation / Python example |
| 157 | + |
| 158 | +#### UI |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | +#### Python interpreter |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | +Python interpreter for now can't use input, so we ask a new code: |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | +#### French translation example |
| 172 | + |
| 173 | + |
0 commit comments