diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index 0433170213..a29da6b09f 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -680,6 +680,25 @@ sliding window based drop off or even before they kick in, this can help in many * extract and include the outline of titles (along with calculated numbering) in the text output of pdftext * ensure that one doesnt recurse beyond a predefined limit. +* Convert NSChatMessage from typedef to Class and update ChatMessageEx, SimpleChat, MultiChatUI classes to + make use of the same. + * helpers consolidated + * helpers to check if given instance contains reasoning or content or toolcall or tool response related + fields/info in them. + * helpers to get the corresponding field values + * some of these helpers where in ChatMessageEx and beyond before + * now the network handshaked fields are declared as undefined by default (instead of empty values). + this ensures that json stringify will automatically discard fields whose values are still undefined. + * add fields wrt tool response and update full flow to directly work with these fields instead of the + xml based serialisation which was previously used for maintaining the different tool response fields + within the content field (and inturn extract from there when sending to server). + * now a dataset based attribute is used to identify when input element contains user input and when + it contains tool call result/response. + * this simplifies the flow wrt showing chat message (also make it appear more cleanly) as well as + identifying not yet accepted tool result and showing in user query input field and related things. + * ALERT: ON-DISK-STORAGE structure of chat sessions have changed wrt tool responses. So old saves will + no longer work wrt tool responses + #### ToDo diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index f7d9de76b5..30f9a837ab 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -253,7 +253,7 @@ class ChatMessageEx { * @param {ChatMessageEx} old */ static newFrom(old) { - return new ChatMessageEx(new NSChatMessage(old.ns.role, old.ns.content, old.ns.reasoning_content, old.ns.tool_calls), old.trimmedContent) + return new ChatMessageEx(new NSChatMessage(old.ns.role, old.ns.content, old.ns.reasoning_content, old.ns.tool_calls, old.ns.tool_call_id, old.ns.name), old.trimmedContent) } clear() { @@ -465,7 +465,7 @@ class SimpleChat { this.iLastSys = ods.iLastSys; this.xchat = []; for (const cur of ods.xchat) { - this.xchat.push(new ChatMessageEx(new NSChatMessage(cur.ns.role, cur.ns.content, cur.ns.reasoning_content, cur.ns.tool_calls), cur.trimmedContent)) + this.xchat.push(new ChatMessageEx(new NSChatMessage(cur.ns.role, cur.ns.content, cur.ns.reasoning_content, cur.ns.tool_calls, cur.ns.tool_call_id, cur.ns.name), cur.trimmedContent)) } } @@ -1053,10 +1053,10 @@ class MultiChatUI { } if (msg.ns.has_toolresponse()) { if (msg.ns.tool_call_id) { - showList.push(['toolcallid', msg.ns.tool_call_id]) + showList.push(['toolcallid', `tool-call-id: ${msg.ns.tool_call_id}`]) } if (msg.ns.name) { - showList.push(['toolname', msg.ns.name]) + showList.push(['toolname', `tool-name: ${msg.ns.name}`]) } } if (msg.ns.getContent().trim().length > 0) {