diff --git a/examples/server/themes/mount-ai/index.html b/examples/server/themes/mount-ai/index.html index ae6521b11..45ec7c08f 100644 --- a/examples/server/themes/mount-ai/index.html +++ b/examples/server/themes/mount-ai/index.html @@ -257,9 +257,10 @@ console.log('already running...'); return; } - + // just in case const suffix = session.value.userMsgSuffix || ""; - const userMsg = msg + suffix; + const prefix = session.value.userMsgPrefix || ""; + const userMsg = prefix + msg + suffix; transcriptUpdate([...session.value.transcript, ["{{user}}", userMsg]]) @@ -276,7 +277,7 @@ data, } ) - ).join("\n"), + ) }); if (selected_image) { prompt = `A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\nUSER:[img-10]${msg}\nASSISTANT:`; @@ -284,7 +285,7 @@ await runLlama(prompt, { ...params.value, slot_id: slot_id, - stop: ["", template("{{char}}"), template("{{user}}")], + stop: ["", template("{{stops}}"), template("{{char}}"), template("{{user}}")], }, "{{char}}"); } diff --git a/examples/server/themes/mount-ai/promptFormats.js b/examples/server/themes/mount-ai/promptFormats.js index e9fc2b71e..ba56a6196 100644 --- a/examples/server/themes/mount-ai/promptFormats.js +++ b/examples/server/themes/mount-ai/promptFormats.js @@ -40,31 +40,39 @@ user: "user", userMsgSuffix: "" }, - +// ---------------------------- "llama3": { -template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|> +template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{{prompt}}{{history}}`, +historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>`, -{{prompt}}<|eot_id|>{{history}}`, -historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|> - -{{message}}`, char: "assistant", +charMsgPrefix: "", +charMsgSuffix: "", + user: "user", -userMsgSuffix: "<|eot_id|>" +userMsgPrefix: "", +userMsgSuffix: "", + +stops: "<|eot_id|>" }, - +// ---------------------------- "phi3": { -template: `{{history}} -{{char}} -`, -historyTemplate: `{{name}} -{{message}}`, -char: "<|assistant|>", -user: "<|user|>", -userMsgSuffix: "<|end|>" +template: `{{history}}{{char}}`, + +historyTemplate: `<|{{name}}|>\n{{message}}<|end|>\n`, + +char: "assistant", +charMsgPrefix: "", +charMsgSuffix: "", + +user: "user", +userMsgPrefix: "", +userMsgSuffix: "", + +stops: "<|end|>" },