SimpleChat: AutoCreate ChatRequestOptions settings to an extent
This commit is contained in:
parent
bc68803605
commit
bb0f0c8a9a
2 changed files with 37 additions and 5 deletions
|
@ -177,6 +177,10 @@ 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
|
modify the existing options value or remove them, for now you can update this global var
|
||||||
using browser's development-tools/console.
|
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
|
||||||
|
created.
|
||||||
|
|
||||||
headers - maintains the list of http headers sent when request is made to the server. By default
|
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
|
Content-Type is set to application/json. Additionally Authorization entry is provided, which can
|
||||||
be set if needed using the settings ui.
|
be set if needed using the settings ui.
|
||||||
|
|
|
@ -817,6 +817,37 @@ class Me {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto create ui input elements for fields in ChatRequestOptions
|
||||||
|
* Currently supports text and number field types.
|
||||||
|
* @param {HTMLDivElement} elDiv
|
||||||
|
*/
|
||||||
|
show_settings_chatrequestoptions(elDiv) {
|
||||||
|
let typeDict = {
|
||||||
|
"string": "text",
|
||||||
|
"number": "number",
|
||||||
|
};
|
||||||
|
let fs = document.createElement("fieldset");
|
||||||
|
let legend = document.createElement("legend");
|
||||||
|
legend.innerText = "ChatRequestOptions";
|
||||||
|
fs.appendChild(legend);
|
||||||
|
elDiv.appendChild(fs);
|
||||||
|
for(const k in this.chatRequestOptions) {
|
||||||
|
let val = this.chatRequestOptions[k];
|
||||||
|
let type = typeof(val);
|
||||||
|
if (!((type == "string") || (type == "number"))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show settings ui for configurable parameters, in the passed Div element.
|
* Show settings ui for configurable parameters, in the passed Div element.
|
||||||
* @param {HTMLDivElement} elDiv
|
* @param {HTMLDivElement} elDiv
|
||||||
|
@ -834,11 +865,6 @@ class Me {
|
||||||
inp.el.placeholder = "Bearer OPENAI_API_KEY";
|
inp.el.placeholder = "Bearer OPENAI_API_KEY";
|
||||||
elDiv.appendChild(inp.div);
|
elDiv.appendChild(inp.div);
|
||||||
|
|
||||||
inp = ui.el_creatediv_input("SetModel", "Model", "text", this.chatRequestOptions["model"], (val)=>{
|
|
||||||
this.chatRequestOptions["model"] = val;
|
|
||||||
});
|
|
||||||
elDiv.appendChild(inp.div);
|
|
||||||
|
|
||||||
let bb = ui.el_creatediv_boolbutton("SetStream", "Stream", {true: "[+] yes stream", false: "[-] do oneshot"}, this.bStream, (val)=>{
|
let bb = ui.el_creatediv_boolbutton("SetStream", "Stream", {true: "[+] yes stream", false: "[-] do oneshot"}, this.bStream, (val)=>{
|
||||||
this.bStream = val;
|
this.bStream = val;
|
||||||
});
|
});
|
||||||
|
@ -869,6 +895,8 @@ class Me {
|
||||||
});
|
});
|
||||||
elDiv.appendChild(sel.div);
|
elDiv.appendChild(sel.div);
|
||||||
|
|
||||||
|
this.show_settings_chatrequestoptions(elDiv);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue