diff --git a/tools/server/public_simplechat/docs/details.md b/tools/server/public_simplechat/docs/details.md index 2a702dfbb4..7be58683da 100644 --- a/tools/server/public_simplechat/docs/details.md +++ b/tools/server/public_simplechat/docs/details.md @@ -266,9 +266,12 @@ It is attached to the document object. Some of these can also be updated using t * NOTE: the latest user message (query/response/...) for which we need a ai response, will also be counted as belonging to the iRecentUserMsgCnt. - * bMarkdown - text contents in the messages are interpreted as Markdown based text and inturn converted to html form for viewing by the end user. + * Markdown - * bMarkdownHtmlSanitize - the text content is sanitized using the browser's dom parser, so that any html tags get converted to normal visually equivalent text representation, before processing by the markdown to html conversion logic. + - enabled: whether markdown support is enabled or not. + - always: if true, all messages text content interpreted as Markdown based text and converted to html for viewing. + if false, then interpret only ai assistant's text content as markdown. + - htmlSanitize: text content sanitized using browser's dom parser, so html/xml tags get converted to normal visually equivalent text representation, before processing by markdown to html conversion logic. * bCompletionFreshChatAlways - whether Completion mode collates complete/sliding-window history when communicating with the server or only sends the latest user query/message. @@ -312,11 +315,11 @@ It is attached to the document object. Some of these can also be updated using t * this is specified in seconds, so that users by default will normally not overload any website through the proxy server. - the builtin tools' meta data is sent to the ai model in the requests sent to it. + 1. the builtin tools' meta data is sent to the ai model in the requests sent to it. - inturn if the ai model requests a tool call to be made, the same will be done and the response sent back to the ai model, under user control, by default. + 2. inturn if the ai model requests a tool call to be made, the same will be done and the response sent back to the ai model, under user control, by default. - as tool calling will involve a bit of back and forth between ai assistant and end user, it is recommended to set iRecentUserMsgCnt to 10 or so, so that enough context is retained during chatting with ai models with tool support. Decide based on your available system and video ram and the type of chat you are having. + 3. as tool calling will involve a bit of back and forth between ai assistant and end user, it is recommended to set iRecentUserMsgCnt to 10 or so, so that enough context is retained during chatting with ai models with tool support. Decide based on your available system and video ram and the type of chat you are having. * 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 676c3385df..56725ad3e4 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -1495,11 +1495,22 @@ class MultiChatUI { if (msg.ns.getContent().trim().length > 0) { showList.push(['content', msg.ns.getContent().trim()]) } + let chatSessionMarkdown = this.simpleChats[chatId].cfg.chatProps.markdown for (const [name, content] of showList) { if (content.length > 0) { - if ((name == "content") && (this.simpleChats[chatId].cfg.chatProps.bMarkdown)) { + let bMarkdown = false + if ((name == "content") && (chatSessionMarkdown.enabled)) { + if (chatSessionMarkdown.always) { + bMarkdown = true + } else { + if (msg.ns.role == Roles.Assistant) { + bMarkdown = true + } + } + } + if (bMarkdown) { entry = document.createElement('div') - let md = new mMD.MarkDown(this.simpleChats[chatId].cfg.chatProps.bMarkdownHtmlSanitize) + let md = new mMD.MarkDown(chatSessionMarkdown.htmlSanitize) md.process(content) entry.innerHTML = md.html secContents.appendChild(entry) @@ -2105,8 +2116,11 @@ export class Config { * * only user messages following the latest system prompt is considered. */ iRecentUserMsgCnt: 5, - bMarkdown: true, - bMarkdownHtmlSanitize: true, + markdown: { + enabled: true, + always: false, + htmlSanitize: true, + }, bCompletionFreshChatAlways: true, bCompletionInsertStandardRolePrefix: false, bTrimGarbage: true, diff --git a/tools/server/public_simplechat/ui.mjs b/tools/server/public_simplechat/ui.mjs index 92984e4beb..13eefb4976 100644 --- a/tools/server/public_simplechat/ui.mjs +++ b/tools/server/public_simplechat/ui.mjs @@ -51,7 +51,7 @@ export function el_create_button(id, callback, name=undefined, innerText=undefin /** * Create a para and set it up. Optionaly append it to a passed parent. - * @param {string} text + * @param {string} text - assigned to innerText * @param {HTMLElement | undefined} elParent * @param {string | undefined} id */