Update local.js

Fixed Local Model usage with reasoning
This commit is contained in:
Sweaterdog 2025-02-12 16:55:12 -08:00 committed by GitHub
parent a245288cb2
commit fd6ac47f07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -51,11 +51,17 @@ export class Local {
const hasCloseTag = res.includes("</think>");
// If there's a partial mismatch, retry to get a complete response.
if ((hasOpenTag && !hasCloseTag) || (!hasOpenTag && hasCloseTag)) {
if ((hasOpenTag && !hasCloseTag)) {
console.warn("Partial <think> block detected. Re-generating...");
continue;
}
// If </think> is present but <think> is not, prepend <think>
if (hasCloseTag && !hasOpenTag) {
res = '<think>' + res;
}
// Changed this so if the model reasons, using <think> and </think> but doesn't start the message with <think>, <think> ges prepended to the message so no error occur.
// If both tags appear, remove them (and everything inside).
if (hasOpenTag && hasCloseTag) {
res = res.replace(/<think>[\s\S]*?<\/think>/g, '');