From aa8c8040cf3f2f60d765591c7b61873f4e070c4f Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Wed, 22 Oct 2025 08:54:15 +0530 Subject: [PATCH] SimpleChatTC:Cleanup:ChatProps: apiEP --- tools/server/public_simplechat/readme.md | 4 ++-- tools/server/public_simplechat/simplechat.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index bf2dc98b6c..779a48adaf 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -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 + 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 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 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, irrespective of whether /chat/completions or /completions endpoint. diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index 557c5f8d00..b58b1f196d 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -774,7 +774,7 @@ class MultiChatUI { if (this.elInUser.disabled) { 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}`; console.error(msg.replace("\n", ":")); alert(msg); @@ -1020,6 +1020,7 @@ class Me { fetchProxyUrl: "http://127.0.0.1:3128" }; this.chatProps = { + apiEP: ApiEP.Type.Chat, stream: true, iRecentUserMsgCnt: 10, bCompletionFreshChatAlways: true, @@ -1035,7 +1036,6 @@ class Me { "Last4": 5, "Last9": 10, }; - this.apiEP = ApiEP.Type.Chat; /** @type {Object} */ this.headers = { "Content-Type": "application/json", @@ -1094,9 +1094,9 @@ class Me { * @param {boolean} bAll */ show_info(elDiv, bAll=false) { - let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "apiEP", "chatProps"]; + let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "chatProps"]; if (!bAll) { - props = [ "baseURL", "modelInfo", "tools", "apiEP", "chatProps" ]; + props = [ "baseURL", "modelInfo", "tools", "chatProps" ]; } fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{ this.modelInfo = { @@ -1112,16 +1112,16 @@ class Me { * @param {HTMLDivElement} 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") { // @ts-ignore elProp.placeholder = "Bearer OPENAI_API_KEY"; } - }, [":apiEP", ":chatProps:iRecentUserMsgCnt"], (propWithPath, prop, elParent)=>{ - if (propWithPath == ":apiEP") { - let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.apiEP, (val)=>{ + }, [":chatProps:apiEP", ":chatProps:iRecentUserMsgCnt"], (propWithPath, prop, elParent)=>{ + if (propWithPath == ":chatProps:apiEP") { + let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.chatProps.apiEP, (val)=>{ // @ts-ignore - this.apiEP = ApiEP.Type[val]; + this.chatProps.apiEP = ApiEP.Type[val]; }); elParent.appendChild(sel.div); }