SimpleChatTC:Cleanup:ChatProps: Move bStream into it

This commit is contained in:
hanishkvc 2025-10-21 23:37:33 +05:30
parent a54fa472dd
commit 7409b29862
2 changed files with 18 additions and 14 deletions

View File

@ -177,7 +177,9 @@ It is attached to the document object. Some of these can also be updated using t
baseURL - the domain-name/ip-address and inturn the port to send the request. baseURL - the domain-name/ip-address and inturn the port to send the request.
bStream - control between oneshot-at-end and live-stream-as-its-generated collating and showing chatProps - maintain a set of properties which manipulate chatting with ai engine
stream - control between oneshot-at-end and live-stream-as-its-generated collating and showing
of the generated response. of the generated response.
the logic assumes that the text sent from the server follows utf-8 encoding. the logic assumes that the text sent from the server follows utf-8 encoding.

View File

@ -459,7 +459,7 @@ class SimpleChat {
for(let k in gMe.apiRequestOptions) { for(let k in gMe.apiRequestOptions) {
obj[k] = gMe.apiRequestOptions[k]; obj[k] = gMe.apiRequestOptions[k];
} }
if (gMe.bStream) { if (gMe.chatProps.stream) {
obj["stream"] = true; obj["stream"] = true;
} }
if (gMe.tools.enabled) { if (gMe.tools.enabled) {
@ -622,7 +622,7 @@ class SimpleChat {
*/ */
async handle_response(resp, apiEP, elDiv) { async handle_response(resp, apiEP, elDiv) {
let theResp = null; let theResp = null;
if (gMe.bStream) { if (gMe.chatProps.stream) {
try { try {
theResp = await this.handle_response_multipart(resp, apiEP, elDiv); theResp = await this.handle_response_multipart(resp, apiEP, elDiv);
this.latestResponse.clear(); this.latestResponse.clear();
@ -1015,11 +1015,13 @@ class Me {
this.baseURL = "http://127.0.0.1:8080"; this.baseURL = "http://127.0.0.1:8080";
this.defaultChatIds = [ "Default", "Other" ]; this.defaultChatIds = [ "Default", "Other" ];
this.multiChat = new MultiChatUI(); this.multiChat = new MultiChatUI();
this.bStream = true;
this.tools = { this.tools = {
enabled: false, enabled: false,
fetchProxyUrl: "http://127.0.0.1:3128" fetchProxyUrl: "http://127.0.0.1:3128"
}; };
this.chatProps = {
stream: true,
}
this.bCompletionFreshChatAlways = true; this.bCompletionFreshChatAlways = true;
this.bCompletionInsertStandardRolePrefix = false; this.bCompletionInsertStandardRolePrefix = false;
this.bTrimGarbage = true; this.bTrimGarbage = true;
@ -1092,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", "bStream", "tools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"]; let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "apiEP", "chatProps", "iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"];
if (!bAll) { if (!bAll) {
props = [ "baseURL", "modelInfo", "headers", "bStream", "tools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt" ]; props = [ "baseURL", "modelInfo", "headers", "tools", "apiRequestOptions", "apiEP", "chatProps", "iRecentUserMsgCnt" ];
} }
fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{ fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{
this.modelInfo = { this.modelInfo = {
@ -1110,7 +1112,7 @@ class Me {
* @param {HTMLDivElement} elDiv * @param {HTMLDivElement} elDiv
*/ */
show_settings(elDiv) { show_settings(elDiv) {
ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "bStream", "tools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "Settings", (prop, elProp)=>{ ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "tools", "apiRequestOptions", "apiEP", "chatProps", "iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "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";