SimpleChatTC:Cleanup:ChatProps: bTrimGarbage

Also remove more inner/detailed stuff from show info in not bAll
mode, given that many of the previous differentiated stuff have
been moved into chatProps and inturn shown for now
This commit is contained in:
hanishkvc 2025-10-22 00:20:41 +05:30
parent 82be13aa33
commit ad65659a63
2 changed files with 18 additions and 18 deletions

View File

@ -208,6 +208,19 @@ It is attached to the document object. Some of these can also be updated using t
bCompletionInsertStandardRolePrefix - whether Completion mode inserts role related prefix wrt the
messages that get inserted into prompt field wrt /Completion endpoint.
bTrimGarbage - whether garbage repeatation at the end of the generated ai response, should be
trimmed or left as is. If enabled, it will be trimmed so that it wont be sent back as part of
subsequent chat history. At the same time the actual trimmed text is shown to the user, once
when it was generated, so user can check if any useful info/data was there in the response.
One may be able to request the ai-model to continue (wrt the last response) (if chat-history
is enabled as part of the chat-history-in-context setting), and chances are the ai-model will
continue starting from the trimmed part, thus allows long response to be recovered/continued
indirectly, in many cases.
The histogram/freq based trimming logic is currently tuned for english language wrt its
is-it-a-alpabetic|numeral-char regex match logic.
tools - contains controls related to tool calling
enabled - control whether tool calling is enabled or not
@ -227,19 +240,6 @@ It is attached to the document object. Some of these can also be updated using t
apiEP - select between /completions and /chat/completions endpoint provided by the server/ai-model.
bTrimGarbage - whether garbage repeatation at the end of the generated ai response, should be
trimmed or left as is. If enabled, it will be trimmed so that it wont be sent back as part of
subsequent chat history. At the same time the actual trimmed text is shown to the user, once
when it was generated, so user can check if any useful info/data was there in the response.
One may be able to request the ai-model to continue (wrt the last response) (if chat-history
is enabled as part of the chat-history-in-context setting), and chances are the ai-model will
continue starting from the trimmed part, thus allows long response to be recovered/continued
indirectly, in many cases.
The histogram/freq based trimming logic is currently tuned for english language wrt its
is-it-a-alpabetic|numeral-char regex match logic.
apiRequestOptions - maintains the list of options/fields to send along with api request,
irrespective of whether /chat/completions or /completions endpoint.

View File

@ -636,7 +636,7 @@ class SimpleChat {
} else {
theResp = await this.handle_response_oneshot(resp, apiEP);
}
if (gMe.bTrimGarbage) {
if (gMe.chatProps.bTrimGarbage) {
let origMsg = theResp.ns.content;
theResp.ns.content = du.trim_garbage_at_end(origMsg);
theResp.trimmedContent = origMsg.substring(theResp.ns.content.length);
@ -1024,8 +1024,8 @@ class Me {
iRecentUserMsgCnt: 10,
bCompletionFreshChatAlways: true,
bCompletionInsertStandardRolePrefix: false,
bTrimGarbage: true,
};
this.bTrimGarbage = true;
/** @type {Object<string, number>} */
this.sRecentUserMsgCnt = {
"Full": -1,
@ -1094,9 +1094,9 @@ class Me {
* @param {boolean} bAll
*/
show_info(elDiv, bAll=false) {
let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "apiEP", "chatProps", "bTrimGarbage"];
let props = ["baseURL", "modelInfo","headers", "tools", "apiRequestOptions", "apiEP", "chatProps"];
if (!bAll) {
props = [ "baseURL", "modelInfo", "headers", "tools", "apiRequestOptions", "apiEP", "chatProps" ];
props = [ "baseURL", "modelInfo", "tools", "apiEP", "chatProps" ];
}
fetch(`${this.baseURL}/props`).then(resp=>resp.json()).then(json=>{
this.modelInfo = {
@ -1112,7 +1112,7 @@ class Me {
* @param {HTMLDivElement} elDiv
*/
show_settings(elDiv) {
ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "tools", "apiRequestOptions", "apiEP", "chatProps", "bTrimGarbage"], "Settings", (prop, elProp)=>{
ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "tools", "apiRequestOptions", "apiEP", "chatProps"], "Settings", (prop, elProp)=>{
if (prop == "headers:Authorization") {
// @ts-ignore
elProp.placeholder = "Bearer OPENAI_API_KEY";