diff --git a/tools/server/public_simplechat/docs/changelog.md b/tools/server/public_simplechat/docs/changelog.md index 747803d6bc..9d642de0a1 100644 --- a/tools/server/public_simplechat/docs/changelog.md +++ b/tools/server/public_simplechat/docs/changelog.md @@ -339,3 +339,10 @@ their respective functionalities. Add support for base64 encoded pdf passing to ai models, when the models and llama engine gain that capability in turn using openai file - file-data type sub block within content array or so ... + +See why the ai streamed response not showing up in TCExternalAi chat session ui, even thou the content is getting +appended to its DivStream. IE why it is hidden. + +Markdown if a line which doesnt have any list marker appears at the same offset level as the last list item, +that too after a new line before this ambiguous line, then maybe pop out 1 level wrt the list. + diff --git a/tools/server/public_simplechat/typemd.mjs b/tools/server/public_simplechat/typemd.mjs index 2b07f417bf..da42938063 100644 --- a/tools/server/public_simplechat/typemd.mjs +++ b/tools/server/public_simplechat/typemd.mjs @@ -109,15 +109,23 @@ export class MarkDown { } } - unwind_list() { - while (true) { + /** + * Unwind till the specified offset level. + * @param {number} unwindTillOffset + */ + unwind_list(unwindTillOffset=-1) { + if (this.in.list.offsets.length == 0) { + return { done: true, remaining: 0 } + } + while (this.in.list.offsets[this.in.list.offsets.length-1] > unwindTillOffset) { + this.in.list.offsets.pop() let popped = this.in.list.endType.pop() - if (popped == undefined) { + this.html += popped; + if (this.in.list.offsets.length == 0) { break } - this.html += popped } - this.in.list.offsets.length = 0 + return { done: true, remaining: this.in.list.offsets.length } } /** @@ -154,20 +162,14 @@ export class MarkDown { this.in.list.endType.push("\n") } } else if (lastOffset > curOffset){ - while (this.in.list.offsets[this.in.list.offsets.length-1] > curOffset) { - this.in.list.offsets.pop() - let popped = this.in.list.endType.pop() - this.html += popped; - if (this.in.list.offsets.length == 0) { - break - } - } + this.unwind_list(curOffset) } this.html += `