SimpleChat: Allow for chat req bool options to be user controlled

This commit is contained in:
HanishKVC 2024-06-15 20:34:35 +05:30
parent 2df373ac40
commit abe6c54c4c
2 changed files with 20 additions and 11 deletions

View file

@ -177,10 +177,15 @@ It is attached to the document object. Some of these can also be updated using t
modify the existing options value or remove them, for now you can update this global var
using browser's development-tools/console.
For string and numeric fields in chatRequestOptions, including even those added by a user
at runtime by directly modifying gMe.chatRequestOptions, setting ui entries will be auto
For string, numeric and boolean fields in chatRequestOptions, including even those added by a
user at runtime by directly modifying gMe.chatRequestOptions, setting ui entries will be auto
created.
cache_prompt option supported by example/server is allowed to be controlled by user. So that
any caching supported with system-prompt and chat history if usable can get used. If one has
enabled chat history sliding window, then the chat history caching may or maynot kick in at
the backend, based on aspects related to positional encoding, attention mechanism etal.
headers - maintains the list of http headers sent when request is made to the server. By default
Content-Type is set to application/json. Additionally Authorization entry is provided, which can
be set if needed using the settings ui.

View file

@ -835,16 +835,20 @@ class Me {
for(const k in this.chatRequestOptions) {
let val = this.chatRequestOptions[k];
let type = typeof(val);
if (!((type == "string") || (type == "number"))) {
continue;
if (((type == "string") || (type == "number"))) {
let inp = ui.el_creatediv_input(`Set${k}`, k, typeDict[type], this.chatRequestOptions[k], (val)=>{
if (type == "number") {
val = Number(val);
}
this.chatRequestOptions[k] = val;
});
fs.appendChild(inp.div);
} else if (type == "boolean") {
let bbtn = ui.el_creatediv_boolbutton(`Set{k}`, k, {true: "true", false: "false"}, val, (userVal)=>{
this.chatRequestOptions[k] = userVal;
});
fs.appendChild(bbtn.div);
}
let inp = ui.el_creatediv_input(`Set${k}`, k, typeDict[type], this.chatRequestOptions[k], (val)=>{
if (type == "number") {
val = Number(val);
}
this.chatRequestOptions[k] = val;
});
fs.appendChild(inp.div);
}
}