|
| 1 | + |
| 2 | +# SimpleChat |
| 3 | + |
| 4 | +by Humans for All. |
| 5 | + |
| 6 | + |
| 7 | +## overview |
| 8 | + |
| 9 | +This simple web frontend, allows triggering/testing the server's /completions or /chat/completions endpoints |
| 10 | +in a simple way with minimal code from a common code base. Inturn additionally it tries to allow single or |
| 11 | +multiple independent back and forth chatting to an extent, with the ai llm model at a basic level, with their |
| 12 | +own system prompts. |
| 13 | + |
| 14 | +The UI follows a responsive web design so that the layout can adapt to available display space in a usable |
| 15 | +enough manner, in general. |
| 16 | + |
| 17 | +NOTE: Given that the idea is for basic minimal testing, it doesnt bother with any model context length and |
| 18 | +culling of old messages from the chat. |
| 19 | + |
| 20 | +NOTE: It doesnt set any parameters other than temperature for now. However if someone wants they can update |
| 21 | +the js file as needed. |
| 22 | + |
| 23 | + |
| 24 | +## usage |
| 25 | + |
| 26 | +One could run this web frontend directly using server itself or if anyone is thinking of adding a built in web |
| 27 | +frontend to configure the server over http(s) or so, then run this web frontend using something like python's |
| 28 | +http module. |
| 29 | + |
| 30 | +### running using examples/server |
| 31 | + |
| 32 | +bin/server -m path/model.gguf --path ../examples/server/public_simplechat [--port PORT] |
| 33 | + |
| 34 | +### running using python3's server module |
| 35 | + |
| 36 | +first run examples/server |
| 37 | +* bin/server -m path/model.gguf |
| 38 | + |
| 39 | +next run this web front end in examples/server/public_simplechat |
| 40 | +* cd ../examples/server/public_simplechat |
| 41 | +* python3 -m http.server PORT |
| 42 | + |
| 43 | +### using the front end |
| 44 | + |
| 45 | +Open this simple web front end from your local browser |
| 46 | +* http://127.0.0.1:PORT/index.html |
| 47 | + |
| 48 | +Once inside |
| 49 | +* Select between chat and completion mode. By default it is set to chat mode. |
| 50 | +* If you want to provide a system prompt, then ideally enter it first, before entering any user query. |
| 51 | + * if chat.add_system_begin is used |
| 52 | + * you cant change the system prompt, after it is has been submitted once along with user query. |
| 53 | + * you cant set a system prompt, after you have submitted any user query |
| 54 | + * if chat.add_system_anytime is used |
| 55 | + * one can change the system prompt any time during chat, by changing the contents of system prompt. |
| 56 | + * inturn the updated/changed system prompt will be inserted into the chat session. |
| 57 | + * this allows for the subsequent user chatting to be driven by the new system prompt set above. |
| 58 | +* Enter your query and either press enter or click on the submit button. |
| 59 | + If you want to insert enter (\n) as part of your chat/query to ai model, use shift+enter. |
| 60 | +* Wait for the logic to communicate with the server and get the response. |
| 61 | + * the user is not allowed to enter any fresh query during this time. |
| 62 | + * the user input box will be disabled and a working message will be shown in it. |
| 63 | +* just refresh the page, to reset wrt the chat history and or system prompt and start afresh. |
| 64 | +* Using NewChat one can start independent chat sessions. |
| 65 | + * two independent chat sessions are setup by default. |
| 66 | + |
| 67 | + |
| 68 | +## Devel note |
| 69 | + |
| 70 | +Sometimes the browser may be stuborn with caching of the file, so your updates to html/css/js |
| 71 | +may not be visible. Also remember that just refreshing/reloading page in browser or for that |
| 72 | +matter clearing site data, dont directly override site caching in all cases. Worst case you may |
| 73 | +have to change port. Or in dev tools of browser, you may be able to disable caching fully. |
| 74 | + |
| 75 | +Concept of multiple chat sessions with different servers, as well as saving and restoring of |
| 76 | +those across browser usage sessions, can be woven around the SimpleChat/MultiChatUI class and |
| 77 | +its instances relatively easily, however given the current goal of keeping this simple, it has |
| 78 | +not been added, for now. |
| 79 | + |
| 80 | +By switching between chat.add_system_begin/anytime, one can control whether one can change |
| 81 | +the system prompt, anytime during the conversation or only at the beginning. |
0 commit comments