SimpleChat:UI: Add Select helper and use it wrt ChatHistoryInCtxt
This commit is contained in:
parent
e42249d82d
commit
1e47a48b30
2 changed files with 42 additions and 0 deletions
|
@ -535,6 +535,12 @@ class Me {
|
||||||
this.bCompletionFreshChatAlways = true;
|
this.bCompletionFreshChatAlways = true;
|
||||||
this.bCompletionInsertStandardRolePrefix = false;
|
this.bCompletionInsertStandardRolePrefix = false;
|
||||||
this.iRecentUserMsgCnt = 2;
|
this.iRecentUserMsgCnt = 2;
|
||||||
|
this.sRecentUserMsgCnt = {
|
||||||
|
"Full": -1,
|
||||||
|
"Last0": 1,
|
||||||
|
"Last1": 2,
|
||||||
|
"Last2": 3,
|
||||||
|
};
|
||||||
// Add needed fields wrt json object to be sent wrt LLM web services completions endpoint.
|
// Add needed fields wrt json object to be sent wrt LLM web services completions endpoint.
|
||||||
this.chatRequestOptions = {
|
this.chatRequestOptions = {
|
||||||
"temperature": 0.7,
|
"temperature": 0.7,
|
||||||
|
@ -580,6 +586,11 @@ class Me {
|
||||||
});
|
});
|
||||||
elDiv.appendChild(bb);
|
elDiv.appendChild(bb);
|
||||||
|
|
||||||
|
let sel = ui.el_create_select("SetChatHistoryInCtxt", Object.keys(this.sRecentUserMsgCnt), "Last0", (val)=>{
|
||||||
|
this.iRecentUserMsgCnt = this.sRecentUserMsgCnt[val];
|
||||||
|
});
|
||||||
|
elDiv.appendChild(sel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,3 +83,34 @@ export function el_create_boolbutton(id, texts, defaultValue, cb) {
|
||||||
})
|
})
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} id
|
||||||
|
* @param {string[]} options
|
||||||
|
* @param {string} defaultOption
|
||||||
|
* @param {function(string):void} cb
|
||||||
|
*/
|
||||||
|
export function el_create_select(id, options, defaultOption, cb) {
|
||||||
|
let el = document.createElement("select");
|
||||||
|
el["xselected"] = defaultOption;
|
||||||
|
el["xoptions"] = structuredClone(options);
|
||||||
|
for(let cur of options) {
|
||||||
|
let op = document.createElement("option");
|
||||||
|
op.value = cur;
|
||||||
|
op.innerText = cur;
|
||||||
|
if (cur == defaultOption) {
|
||||||
|
op.selected = true;
|
||||||
|
}
|
||||||
|
el.appendChild(op);
|
||||||
|
}
|
||||||
|
if (id) {
|
||||||
|
el.id = id;
|
||||||
|
el.name = id;
|
||||||
|
}
|
||||||
|
el.addEventListener('click', (ev)=>{
|
||||||
|
let target = /** @type{HTMLSelectElement} */(ev.target);
|
||||||
|
console.log("DBUG:UI:Select:", id, ":", target.value);
|
||||||
|
cb(target.value);
|
||||||
|
})
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue