SimpleChat: Move handling systemprompt into its own func

This commit is contained in:
HanishKVC 2024-05-18 03:19:59 +05:30
parent 72151aa634
commit 601fedf8c1

View file

@ -89,15 +89,12 @@ class SimpleChat {
} }
/**
* Handle submit request by user
* @param {HTMLInputElement} inputSystem
* @param {HTMLInputElement} inputUser
* @param {HTMLDivElement} divChat
* @param {string} apiEP
*/
async function handle_submit(inputSystem, inputUser, divChat, apiEP) {
/**
* Handle setting of system prompt.
* @param {HTMLInputElement} inputSystem
*/
function handle_systemprompt(inputSystem) {
let sysPrompt = inputSystem.value; let sysPrompt = inputSystem.value;
if (gChat.xchat.length == 0) { if (gChat.xchat.length == 0) {
if (sysPrompt.length > 0) { if (sysPrompt.length > 0) {
@ -114,6 +111,18 @@ async function handle_submit(inputSystem, inputUser, divChat, apiEP) {
} }
} }
} }
}
/**
* Handle submit request by user
* @param {HTMLInputElement} inputSystem
* @param {HTMLInputElement} inputUser
* @param {HTMLDivElement} divChat
* @param {string} apiEP
*/
async function handle_submit(inputSystem, inputUser, divChat, apiEP) {
handle_systemprompt(inputSystem);
let content = inputUser?.value; let content = inputUser?.value;
if (!gChat.add(Roles.User, content)) { if (!gChat.add(Roles.User, content)) {