SimpleChatTCRV:Config++:Save/Load Configs
This commit is contained in:
parent
f7e9bdeed5
commit
57cf87b19a
|
|
@ -885,10 +885,13 @@ Cleanup in general
|
||||||
* ensures that the available list of tool calls match the config of the chat session involved.
|
* ensures that the available list of tool calls match the config of the chat session involved.
|
||||||
Needed as user could change tools related proxy server url.
|
Needed as user could change tools related proxy server url.
|
||||||
* next setup the main ui as needed.
|
* next setup the main ui as needed.
|
||||||
|
* Hide user-input area and tool call validate/trigger area when switching into settings and ensure they
|
||||||
|
get unhidden when returning back, as needed.
|
||||||
|
* Save and restore ChatSession config entries, as needed, in localStorage.
|
||||||
|
* load previously saved config if any, when creating ChatSession
|
||||||
|
* when ever switching, including into a, ChatSession, Configs of all chat sessions are saved.
|
||||||
* TODO
|
* TODO
|
||||||
* Need to save and restore ChatSession config entries.
|
|
||||||
* Need to allow any changes to proxyUrl to trigger a new tool manager setup wrt that chat session.
|
* Need to allow any changes to proxyUrl to trigger a new tool manager setup wrt that chat session.
|
||||||
* Need to hide user-input area and tool call validate/trigger area when switching into settings
|
|
||||||
|
|
||||||
|
|
||||||
#### ToDo
|
#### ToDo
|
||||||
|
|
|
||||||
|
|
@ -542,6 +542,7 @@ export class SimpleChat {
|
||||||
this.latestResponse = new ChatMessageEx();
|
this.latestResponse = new ChatMessageEx();
|
||||||
this.cfg = Config.clone(cfg);
|
this.cfg = Config.clone(cfg);
|
||||||
this.toolsMgr = toolsMgr
|
this.toolsMgr = toolsMgr
|
||||||
|
this.load_cfg()
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
|
@ -571,6 +572,30 @@ export class SimpleChat {
|
||||||
return `SimpleChat-${this.chatId}`
|
return `SimpleChat-${this.chatId}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the config to local storage
|
||||||
|
*/
|
||||||
|
save_cfg() {
|
||||||
|
let tag = `SimpleChat:SaveCfg:${this.chatId}`;
|
||||||
|
let ods = JSON.stringify(this.cfg)
|
||||||
|
localStorage.setItem(this.ods_key(), ods)
|
||||||
|
console.log(`DBUG:${tag}:saved`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the config from local storage
|
||||||
|
*/
|
||||||
|
load_cfg() {
|
||||||
|
let tag = `SimpleChat:LoadCfg:${this.chatId}`;
|
||||||
|
let odsStr = localStorage.getItem(this.ods_key())
|
||||||
|
if (odsStr) {
|
||||||
|
this.cfg = Object.assign(this.cfg, JSON.parse(odsStr))
|
||||||
|
console.log(`DBUG:${tag}:loaded`)
|
||||||
|
} else {
|
||||||
|
console.log(`DBUG:${tag}:nothing to load`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save into indexedDB
|
* Save into indexedDB
|
||||||
*/
|
*/
|
||||||
|
|
@ -1926,6 +1951,15 @@ class MultiChatUI {
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save configs wrt all the currently loaded sessions
|
||||||
|
*/
|
||||||
|
save_sessions_cfgs() {
|
||||||
|
for (const cid of Object.keys(this.simpleChats)) {
|
||||||
|
this.simpleChats[cid].save_cfg()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch ui to the specified chatId and set curChatId to same.
|
* Switch ui to the specified chatId and set curChatId to same.
|
||||||
* @param {string} chatId
|
* @param {string} chatId
|
||||||
|
|
@ -1939,6 +1973,7 @@ class MultiChatUI {
|
||||||
console.error(`ERRR:SimpleChat:MCUI:HandleSessionSwitch:${chatId} missing...`);
|
console.error(`ERRR:SimpleChat:MCUI:HandleSessionSwitch:${chatId} missing...`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.save_sessions_cfgs()
|
||||||
this.elDivUserIn.hidden = false
|
this.elDivUserIn.hidden = false
|
||||||
this.elInSystem.value = chat.get_system_latest().ns.getContent();
|
this.elInSystem.value = chat.get_system_latest().ns.getContent();
|
||||||
this.curChatId = chatId;
|
this.curChatId = chatId;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue