Skip to content

Commit 72e7a8d

Browse files
committed
SimpleChatTC:Reasoning: Cleanup the initial go
Rather simplify and make the content_equiv provide a relatively simple and neat representation of the reasoning with content and toolcall as the cases may be. Also remove the partial new para that I had introduced in the initial go for reasoning.
1 parent 61dde69 commit 72e7a8d

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

tools/server/public_simplechat/simplechat.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,25 @@ class ChatMessageEx {
251251
return true
252252
}
253253

254+
/**
255+
* Collate all the different parts of a chat message into a single string object.
256+
*
257+
* This currently includes reasoning, content and toolcall parts.
258+
*/
254259
content_equiv() {
255260
let reasoning = ""
261+
let content = ""
262+
let toolcall = ""
256263
if (this.ns.reasoning_content.trim() !== "") {
257-
reasoning = this.ns.reasoning_content.trim()
264+
reasoning = `!!!Reasoning: ${this.ns.reasoning_content.trim()} !!!\n`;
258265
}
259266
if (this.ns.content !== "") {
260-
if (reasoning !== "") {
261-
return `!!!Reasoning: ${reasoning}!!! ${this.ns.content}`;
262-
}
263-
return this.ns.content;
264-
} else if (this.has_toolcall()) {
265-
let ret = ""
266-
if (reasoning !== "") {
267-
ret = `!!!Reasoning: ${reasoning}!!!`
268-
}
269-
return `${ret}<tool_call>\n<tool_name>${this.ns.tool_calls[0].function.name}</tool_name>\n<tool_args>${this.ns.tool_calls[0].function.arguments}</tool_args>\n</tool_call>`;
270-
} else {
271-
return ""
267+
content = this.ns.content;
272268
}
269+
if (this.has_toolcall()) {
270+
toolcall = `\n\n<tool_call>\n<tool_name>${this.ns.tool_calls[0].function.name}</tool_name>\n<tool_args>${this.ns.tool_calls[0].function.arguments}</tool_args>\n</tool_call>\n`;
271+
}
272+
return `${reasoning} ${content} ${toolcall}`;
273273
}
274274

275275
}
@@ -495,10 +495,6 @@ class SimpleChat {
495495
let last = undefined;
496496
for(const x of this.recent_chat(gMe.chatProps.iRecentUserMsgCnt)) {
497497
if (x.ns.role != Roles.ToolTemp) {
498-
if (x.ns.reasoning_content.trim() === "") {
499-
let entry = ui.el_create_append_p(`>>${x.ns.role}!<<: ${x.ns.reasoning_content}`, div);
500-
entry.className = `role-${x.ns.role}`;
501-
}
502498
let entry = ui.el_create_append_p(`${x.ns.role}: ${x.content_equiv()}`, div);
503499
entry.className = `role-${x.ns.role}`;
504500
last = entry;

0 commit comments

Comments
 (0)