webui: synchronize context size value for clientside warning

This commit is contained in:
mappu 2023-04-08 15:48:16 +12:00
parent dc8db75e04
commit 2cdcf54dd8
2 changed files with 15 additions and 13 deletions

22
api.go
View File

@ -12,6 +12,17 @@ import (
*/
import "C"
// Constant LLaMA parameters
const (
ParamContextSize = 512 // RAM requirements: 512 needs 800MB KV (~3216MB overall), 2048 needs 3200MB KV (~??? overall)
ParamTopK = 40
ParamTopP = 0.95
ParamTemperature = 0.08
ParamRepeatPenalty = 1.10
ParamRepeatPenaltyWindowSize = 64
)
func (this *Application) POST_Chat(w http.ResponseWriter, r *http.Request) {
flusher, ok := w.(http.Flusher)
if !ok {
@ -52,17 +63,6 @@ func (this *Application) POST_Chat(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
flusher.Flush() // Flush before any responses, so the webui knows things are happening
// Constant LLaMA parameters
const (
ParamContextSize = 512 // RAM requirements: 512 needs 800MB KV (~3216MB overall), 2048 needs 3200MB KV (~??? overall)
ParamTopK = 40
ParamTopP = 0.95
ParamTemperature = 0.08
ParamRepeatPenalty = 1.10
ParamRepeatPenaltyWindowSize = 64
)
// Start a new LLaMA session
lparams := C.llama_context_default_params()

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"html"
"net/http"
@ -44,7 +45,8 @@ button {
<button id="interrupt" disabled> Interrupt</button>
<script type="text/javascript">
function main() {
let conversationID = "` + uuid.New().String() + `";
const conversationID = "` + uuid.New().String() + `";
const contextSize = ` + fmt.Sprintf("%d", ParamContextSize) + `;
const apiKey = "public-web-interface";
const $generate = document.getElementById("generate");
@ -53,7 +55,7 @@ function main() {
$generate.addEventListener('click', async function() {
const content = $main.value;
if (content.split(" ").length >= 2047) {
if (content.split(" ").length >= (contextSize-4)) {
if (! confirm("Warning: high prompt length, the model will forget part of the content. Are you sure you want to continue?")) {
return;
}