SimpleChatTC:ChatMessageEx: ods load, system prompt related
these have been updated to work with ChatMessageEx to an extent
This commit is contained in:
parent
abbf927557
commit
343d414dd3
|
|
@ -179,7 +179,7 @@ let gUsageMsg = `
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
/** @typedef {{role: string, content: string}[]} ChatMessages */
|
/** @typedef {ChatMessageEx[]} ChatMessages */
|
||||||
|
|
||||||
/** @typedef {{iLastSys: number, xchat: ChatMessages}} SimpleChatODS */
|
/** @typedef {{iLastSys: number, xchat: ChatMessages}} SimpleChatODS */
|
||||||
|
|
||||||
|
|
@ -222,7 +222,11 @@ class SimpleChat {
|
||||||
/** @type {SimpleChatODS} */
|
/** @type {SimpleChatODS} */
|
||||||
let ods = JSON.parse(sods);
|
let ods = JSON.parse(sods);
|
||||||
this.iLastSys = ods.iLastSys;
|
this.iLastSys = ods.iLastSys;
|
||||||
this.xchat = ods.xchat;
|
this.xchat = [];
|
||||||
|
for (const cur of ods.xchat) {
|
||||||
|
// TODO: May have to account for missing fields
|
||||||
|
this.xchat.push(new ChatMessageEx(cur.ns.role, cur.ns.content, cur.ns.tool_calls, cur.trimmedContent))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -410,10 +414,10 @@ class SimpleChat {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sysPrompt.length > 0) {
|
if (sysPrompt.length > 0) {
|
||||||
if (this.xchat[0].role !== Roles.System) {
|
if (this.xchat[0].ns.role !== Roles.System) {
|
||||||
console.error(`ERRR:SimpleChat:SC:${msgTag}:You need to specify system prompt before any user query, ignoring...`);
|
console.error(`ERRR:SimpleChat:SC:${msgTag}:You need to specify system prompt before any user query, ignoring...`);
|
||||||
} else {
|
} else {
|
||||||
if (this.xchat[0].content !== sysPrompt) {
|
if (this.xchat[0].ns.content !== sysPrompt) {
|
||||||
console.error(`ERRR:SimpleChat:SC:${msgTag}:You cant change system prompt, mid way through, ignoring...`);
|
console.error(`ERRR:SimpleChat:SC:${msgTag}:You cant change system prompt, mid way through, ignoring...`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -437,7 +441,7 @@ class SimpleChat {
|
||||||
return this.add(Roles.System, sysPrompt);
|
return this.add(Roles.System, sysPrompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastSys = this.xchat[this.iLastSys].content;
|
let lastSys = this.xchat[this.iLastSys].ns.content;
|
||||||
if (lastSys !== sysPrompt) {
|
if (lastSys !== sysPrompt) {
|
||||||
return this.add(Roles.System, sysPrompt);
|
return this.add(Roles.System, sysPrompt);
|
||||||
}
|
}
|
||||||
|
|
@ -451,7 +455,7 @@ class SimpleChat {
|
||||||
if (this.iLastSys == -1) {
|
if (this.iLastSys == -1) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
let sysPrompt = this.xchat[this.iLastSys].content;
|
let sysPrompt = this.xchat[this.iLastSys].ns.content;
|
||||||
return sysPrompt;
|
return sysPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue