Skip to content

Commit a644cb3

Browse files
committed
SimpleChatTC:ChatMessageEx:While at it also ns_delete
these common helpers avoid needing ignore tagging to ts-check, in places where valid constructs have been used which go beyond strict structured js handling that is tried to be achieved using it, but are still valid and legal.
1 parent 4efa232 commit a644cb3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tools/server/public_simplechat/simplechat.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ class ChatMessageEx {
115115
this.ns[key] = value
116116
}
117117

118+
/**
119+
* Remove specified key and its value from ns object
120+
* @param {string | number} key
121+
*/
122+
ns_delete(key) {
123+
// @ts-ignore
124+
delete(this.ns[key])
125+
}
126+
118127
/**
119128
* Update based on the drip by drip data got from network in streaming mode.
120129
* Tries to support both Chat and Completion endpoints
@@ -329,8 +338,7 @@ class SimpleChat {
329338
for (const msg of xchat) {
330339
let tmsg = ChatMessageEx.newFrom(msg);
331340
if (!tmsg.has_toolcall()) {
332-
// @ts-ignore
333-
delete(tmsg.ns.tool_calls)
341+
tmsg.ns_delete("tool_calls")
334342
}
335343
if (tmsg.ns.role == Roles.Tool) {
336344
let res = ChatMessageEx.extractToolCallResultAllInOne(tmsg.ns.content)

0 commit comments

Comments
 (0)