SimpleChatTC:Load allows old and new ChatMessage(Ex) formats

This commit is contained in:
hanishkvc 2025-10-14 23:27:03 +05:30
parent 475858a4b3
commit 2ef201ff8d
1 changed files with 7 additions and 2 deletions

View File

@ -224,8 +224,13 @@ class SimpleChat {
this.iLastSys = ods.iLastSys; this.iLastSys = ods.iLastSys;
this.xchat = []; this.xchat = [];
for (const cur of ods.xchat) { for (const cur of ods.xchat) {
// TODO: May have to account for missing fields if (cur.ns == undefined) {
this.xchat.push(new ChatMessageEx(cur.ns.role, cur.ns.content, cur.ns.tool_calls, cur.trimmedContent)) /** @typedef {{role: string, content: string}} OldChatMessage */
let tcur = /** @type {OldChatMessage} */(/** @type {unknown} */(cur));
this.xchat.push(new ChatMessageEx(tcur.role, tcur.content))
} else {
this.xchat.push(new ChatMessageEx(cur.ns.role, cur.ns.content, cur.ns.tool_calls, cur.trimmedContent))
}
} }
} }