SimpleChat:ODS:Move restore/load saved chat btn setup to Me

This also allows being able to set the common system prompt
ui element to loaded chat's system prompt.
This commit is contained in:
HanishKVC 2024-05-31 00:47:20 +05:30
parent 5d408660f2
commit 4abcfde4e7

View file

@ -189,15 +189,7 @@ class SimpleChat {
} else {
if (bClear) {
div.innerHTML = gUsageMsg;
div.innerHTML += `<p class="role-system">Restore</p>`;
let btn = ui.el_create_button(this.ods_key(), (ev)=>{
console.log("DBUG:SimpleChat:SC:Load", this);
this.load();
queueMicrotask(()=>{
this.show(div);
});
});
div.appendChild(btn);
gMe.setup_load(div, this);
gMe.show_info(div);
}
}
@ -768,6 +760,25 @@ class Me {
};
}
/**
* Setup the load saved chat ui.
* @param {HTMLDivElement} div
* @param {SimpleChat} chat
*/
setup_load(div, chat) {
div.innerHTML += `<p class="role-system">Restore</p>
<p>Load previously saved chat session, if available</p>`;
let btn = ui.el_create_button(chat.ods_key(), (ev)=>{
console.log("DBUG:SimpleChat:SC:Load", chat);
chat.load();
queueMicrotask(()=>{
chat.show(div);
this.multiChat.elInSystem.value = chat.get_system_latest();
});
});
div.appendChild(btn);
}
/**
* Show the configurable parameters info in the passed Div element.
* @param {HTMLDivElement} elDiv