From b2d53c1e14c5797eb6516ee7985a8575a89354f4 Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Sat, 8 Nov 2025 14:21:47 +0530 Subject: [PATCH] SimpleChatTC:ChatMessage undefined driven Switch from empty strings or empty list and so to undefined. undefined will be treated by Javascript and JSON to mean, not even instantiated and also dont instantiate the same --- tools/server/public_simplechat/simplechat.js | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index 022d26744f..ae5d502496 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -46,7 +46,12 @@ class ApiEP { */ /** - * @typedef {{role: string, content: string, reasoning_content: string, tool_calls: Array}} NSChatMessage + * @typedef {{ + * role: string, + * content: string|undefined, + * reasoning_content: string|undefined, + * tool_calls: Array|undefined + * }} NSChatMessage */ class ChatMessageEx { @@ -54,12 +59,12 @@ class ChatMessageEx { /** * Represent a Message in the Chat * @param {string} role - * @param {string} content - * @param {string} reasoning_content - * @param {Array} tool_calls - * @param {string} trimmedContent + * @param {string|undefined} content + * @param {string|undefined} reasoning_content + * @param {Array|undefined} tool_calls + * @param {string|undefined} trimmedContent */ - constructor(role = "", content="", reasoning_content="", tool_calls=[], trimmedContent="") { + constructor(role = "", content=undefined, reasoning_content=undefined, tool_calls=undefined, trimmedContent=undefined) { /** @type {NSChatMessage} */ this.ns = { role: role, content: content, tool_calls: tool_calls, reasoning_content: reasoning_content } this.trimmedContent = trimmedContent; @@ -75,10 +80,10 @@ class ChatMessageEx { clear() { this.ns.role = ""; - this.ns.content = ""; - this.ns.reasoning_content = ""; - this.ns.tool_calls = []; - this.trimmedContent = ""; + this.ns.content = undefined; + this.ns.reasoning_content = undefined; + this.ns.tool_calls = undefined; + this.trimmedContent = undefined; } /**