Skip to content

Commit 4abcfde

Browse files
committed
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.
1 parent 5d40866 commit 4abcfde

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

examples/server/public_simplechat/simplechat.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,7 @@ class SimpleChat {
189189
} else {
190190
if (bClear) {
191191
div.innerHTML = gUsageMsg;
192-
div.innerHTML += `<p class="role-system">Restore</p>`;
193-
let btn = ui.el_create_button(this.ods_key(), (ev)=>{
194-
console.log("DBUG:SimpleChat:SC:Load", this);
195-
this.load();
196-
queueMicrotask(()=>{
197-
this.show(div);
198-
});
199-
});
200-
div.appendChild(btn);
192+
gMe.setup_load(div, this);
201193
gMe.show_info(div);
202194
}
203195
}
@@ -768,6 +760,25 @@ class Me {
768760
};
769761
}
770762

763+
/**
764+
* Setup the load saved chat ui.
765+
* @param {HTMLDivElement} div
766+
* @param {SimpleChat} chat
767+
*/
768+
setup_load(div, chat) {
769+
div.innerHTML += `<p class="role-system">Restore</p>
770+
<p>Load previously saved chat session, if available</p>`;
771+
let btn = ui.el_create_button(chat.ods_key(), (ev)=>{
772+
console.log("DBUG:SimpleChat:SC:Load", chat);
773+
chat.load();
774+
queueMicrotask(()=>{
775+
chat.show(div);
776+
this.multiChat.elInSystem.value = chat.get_system_latest();
777+
});
778+
});
779+
div.appendChild(btn);
780+
}
781+
771782
/**
772783
* Show the configurable parameters info in the passed Div element.
773784
* @param {HTMLDivElement} elDiv

0 commit comments

Comments
 (0)