Skip to content

Commit 23900f7

Browse files
poulphunterVotre NomtjohnmanJohnmanggerganov
authored
Server webui translations, UI/UX improvements, presets and suggestion ideas
* add translations packages * add translations packages * begining of translation * Check for reverse prompt by characters instead of tokens (ggml-org#292) (ggml-org#330) * Check for reverse prompt by characters instead of tokens (ggml-org#292) * Update main.cpp Wording. * Cleanup. * Remove unnecessary use of std::stringstream. --------- Co-authored-by: Johnman <tjohnman@github> Co-authored-by: Georgi Gerganov <[email protected]> * metal : fix `ggml_metal_log` vargs (ggml-org#4373) * docs: utilize the forward slash (/) as the path separator for Unix-like systems (ggml-org#11770) * close dropdown Menu function * no export here * automatic close sidebar when choice is made (mobile UX improvement) * fix closeDropDownMenu * Translation config in Header now * Translation config in Header now * French promt example * continue translation * continue translation * change refreshing when language is selected will use first config in json file if present and if in the correct language * Add languages and translations * fix loading when no prompt from language is found * fix click on manual settings if already checked in dropdown * rename Sidebar to ConversationList, better understanding, refactor code to have all that concerns this component in the same place * rename Sidebar to ConversationList, better understanding, refactor code to have all that concerns this component in the same place * rename Sidebar to ConversationList, better understanding, refactor code to have all that concerns this component in the same place * UI improvements UX is easier to understand * json reformat * UI buttons margins * configs and language selection in appcontext, improve UI * continue translation * add favicon (no more console log errors) * start changing Setting Dialog * fix color in light/auto theme * fix color in light/auto theme * UX/UI improvements, no more drawer * code refactor * code refactor, continue translation, UX/UI improvements * fix key * format * format * loading / save presets * translations * build * embed translations * remove log * code refactor, main functions in app.context * build * fix not needed, revert * New README.md for Web UI app. * prompts renamed to presets * favicon * remove unused parameter in json preset files * add favicon (no more console logs) * new build * readme and screenshoots --------- Co-authored-by: Votre Nom <[email protected]> Co-authored-by: tjohnman <[email protected]> Co-authored-by: Johnman <tjohnman@github> Co-authored-by: Georgi Gerganov <[email protected]> Co-authored-by: Finn Voorhees <[email protected]> Co-authored-by: jason_w <[email protected]> Co-authored-by: poulphunter <>
1 parent 823ad4c commit 23900f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3611
-2109
lines changed

examples/server/README.md

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -219,42 +219,7 @@ services:
219219

220220
## Web UI
221221

222-
The project includes a web-based user interface that enables interaction with the model through the `/chat/completions` endpoint.
223-
224-
The web UI is developed using:
225-
- `react` framework for frontend development
226-
- `tailwindcss` and `daisyui` for styling
227-
- `vite` for build tooling
228-
229-
A pre-built version is available as a single HTML file under `/public` directory.
230-
231-
To build or to run the dev server (with hot reload):
232-
233-
```sh
234-
# make sure you have nodejs installed
235-
cd examples/server/webui
236-
npm i
237-
238-
# to run the dev server
239-
npm run dev
240-
241-
# to build the public/index.html.gz
242-
npm run build
243-
```
244-
After `public/index.html.gz` has been generated we need to generate the c++
245-
headers (like build/examples/server/index.html.gz.hpp) that will be included
246-
by server.cpp. This is done by building `llama-server` as described in the
247-
[build](#build) section above.
248-
249-
Prompt and other configuration parameters are easily customisable with the json file `public/prompts.config.json`.
250-
You can rename `public/prompts.config.json.example` to `public/prompts.config.json` to make it work.
251-
Examples from https://github.com/f/awesome-chatgpt-prompts have been already written in it.
252-
253-
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 snippet in browser's console:
254-
255-
```js
256-
localStorage.setItem('base', 'http://localhost:8080')
257-
```
222+
See [README.md](./webui/README.md)
258223

259224
## Quick Start
260225

34.2 KB
Loading

examples/server/public/index.html.gz

39.8 KB
Binary file not shown.

examples/server/public/prompts.config.json.example renamed to examples/server/public/prompts.config.example.json

Lines changed: 256 additions & 426 deletions
Large diffs are not rendered by default.

examples/server/webui/README.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
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+
![Mobile Python Example Ask 1](doc/mobile_python_example_ask1.png 'Mobile Python Example Ask 1')
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+
![desktop_dark_theme_presets_suggestions.png](doc/desktop_dark_theme_presets_suggestions.png)
150+
![desktop_light_theme_presets_suggestions.png](doc/desktop_light_theme_presets_suggestions.png)
151+
152+
### Medium devices
153+
154+
![iPad_conversation_Italy.png](doc/iPad_conversation_Italy.png)
155+
156+
### Mobile / UI / Translation / Python example
157+
158+
#### UI
159+
160+
![mobile_conversation_tab.png](doc/mobile_conversation_tab.png)
161+
![mobile_settings.png](doc/mobile_settings.png)
162+
163+
#### Python interpreter
164+
165+
![Mobile Python Example Ask 1](doc/mobile_python_example_ask1.png 'Mobile Python Example Ask 1')
166+
167+
Python interpreter for now can't use input, so we ask a new code:
168+
![Mobile Python Example Ask 2](doc/mobile_python_example_ask2.png 'Mobile Python Example Ask 2')
169+
![Mobile Python Example Run](doc/mobile_python_example_run.png 'Mobile Python Example Run')
170+
171+
#### French translation example
172+
173+
![mobile_french_translation_example.png](doc/mobile_french_translation_example.png)
34.2 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
15.6 KB
Loading

examples/server/webui/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
content="width=device-width, initial-scale=1, maximum-scale=1"
88
/>
99
<meta name="color-scheme" content="light dark" />
10-
<title>🦙 llama.cpp - chat</title>
10+
<link rel="icon" type="image/png" href="assets/favicon.png" />
11+
<title>llama.cpp - chat</title>
1112
</head>
1213
<body>
1314
<div id="root"></div>
14-
<script type="module" src="/src/main.tsx"></script>
15+
<script type="module" src="src/main.tsx"></script>
1516
</body>
1617
</html>

0 commit comments

Comments
 (0)