SimpleChatTC:NSChatMessage:Tool role newFromOld and load fixup

Had forgotten to update these two functions wrt the tool response
related new fields. This is fixed now.

Also show tool-call-id and tool-name to end user as part of chat
message showing.

ALERT on disk structure change old saves wont work esp wrt tool
responses
This commit is contained in:
hanishkvc 2025-11-08 21:45:51 +05:30
parent b9defe2843
commit b4aaf5bd1b
2 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -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) {