SimpleChatTC:Cleanup:ChatProps: apiEP

This commit is contained in:
hanishkvc 2025-10-22 08:54:15 +05:30
parent ad65659a63
commit aa8c8040cf
2 changed files with 11 additions and 11 deletions

View File

@ -179,6 +179,8 @@ It is attached to the document object. Some of these can also be updated using t
chatProps - maintain a set of properties which manipulate chatting with ai engine chatProps - maintain a set of properties which manipulate chatting with ai engine
apiEP - select between /completions and /chat/completions endpoint provided by the server/ai-model.
stream - control between oneshot-at-end and live-stream-as-its-generated collating and showing stream - control between oneshot-at-end and live-stream-as-its-generated collating and showing
of the generated response. of the generated response.
@ -238,8 +240,6 @@ It is attached to the document object. Some of these can also be updated using t
recommended to set iRecentUserMsgCnt to 10 or more, so that enough context is retained during recommended to set iRecentUserMsgCnt to 10 or more, so that enough context is retained during
chatting with ai models with tool support. chatting with ai models with tool support.
apiEP - select between /completions and /chat/completions endpoint provided by the server/ai-model.
apiRequestOptions - maintains the list of options/fields to send along with api request, apiRequestOptions - maintains the list of options/fields to send along with api request,
irrespective of whether /chat/completions or /completions endpoint. irrespective of whether /chat/completions or /completions endpoint.

View File

@ -774,7 +774,7 @@ class MultiChatUI {
if (this.elInUser.disabled) { if (this.elInUser.disabled) {
return; return;
} }
this.handle_user_submit(this.curChatId, gMe.apiEP).catch((/** @type{Error} */reason)=>{ this.handle_user_submit(this.curChatId, gMe.chatProps.apiEP).catch((/** @type{Error} */reason)=>{
let msg = `ERRR:SimpleChat\nMCUI:HandleUserSubmit:${this.curChatId}\n${reason.name}:${reason.message}`; let msg = `ERRR:SimpleChat\nMCUI:HandleUserSubmit:${this.curChatId}\n${reason.name}:${reason.message}`;
console.error(msg.replace("\n", ":")); console.error(msg.replace("\n", ":"));
alert(msg); alert(msg);
@ -1020,6 +1020,7 @@ class Me {
fetchProxyUrl: "http://127.0.0.1:3128" fetchProxyUrl: "http://127.0.0.1:3128"
}; };
this.chatProps = { this.chatProps = {
apiEP: ApiEP.Type.Chat,
stream: true, stream: true,
iRecentUserMsgCnt: 10, iRecentUserMsgCnt: 10,
bCompletionFreshChatAlways: true, bCompletionFreshChatAlways: true,
@ -1035,7 +1036,6 @@ class Me {
"Last4": 5, "Last4": 5,
"Last9": 10, "Last9": 10,
}; };
this.apiEP = ApiEP.Type.Chat;
/** @type {Object<string, string>} */ /** @type {Object<string, string>} */
this.headers = { this.headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -1094,9 +1094,9 @@ class Me {
* @param {boolean} bAll * @param {boolean} bAll
*/ */
show_info(elDiv, bAll=false) { show_info(elDiv, bAll=false) {
let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "apiEP", "chatProps"]; let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "chatProps"];
if (!bAll) { if (!bAll) {
props = [ "baseURL", "modelInfo", "tools", "apiEP", "chatProps" ]; props = [ "baseURL", "modelInfo", "tools", "chatProps" ];
} }
fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{ fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{
this.modelInfo = { this.modelInfo = {
@ -1112,16 +1112,16 @@ class Me {
* @param {HTMLDivElement} elDiv * @param {HTMLDivElement} elDiv
*/ */
show_settings(elDiv) { show_settings(elDiv) {
ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "tools", "apiRequestOptions", "apiEP", "chatProps"], "Settings", (prop, elProp)=>{ ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "tools", "apiRequestOptions", "chatProps"], "Settings", (prop, elProp)=>{
if (prop == "headers:Authorization") { if (prop == "headers:Authorization") {
// @ts-ignore // @ts-ignore
elProp.placeholder = "Bearer OPENAI_API_KEY"; elProp.placeholder = "Bearer OPENAI_API_KEY";
} }
}, [":apiEP", ":chatProps:iRecentUserMsgCnt"], (propWithPath, prop, elParent)=>{ }, [":chatProps:apiEP", ":chatProps:iRecentUserMsgCnt"], (propWithPath, prop, elParent)=>{
if (propWithPath == ":apiEP") { if (propWithPath == ":chatProps:apiEP") {
let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.apiEP, (val)=>{ let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.chatProps.apiEP, (val)=>{
// @ts-ignore // @ts-ignore
this.apiEP = ApiEP.Type[val]; this.chatProps.apiEP = ApiEP.Type[val];
}); });
elParent.appendChild(sel.div); elParent.appendChild(sel.div);
} }