From fd6ac47f07ed38c3ae091f48664dadc74ab83e24 Mon Sep 17 00:00:00 2001 From: Sweaterdog Date: Wed, 12 Feb 2025 16:55:12 -0800 Subject: [PATCH] Update local.js Fixed Local Model usage with reasoning --- src/models/local.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/models/local.js b/src/models/local.js index 509085a..fafa3d8 100644 --- a/src/models/local.js +++ b/src/models/local.js @@ -51,11 +51,17 @@ export class Local { const hasCloseTag = res.includes(""); // If there's a partial mismatch, retry to get a complete response. - if ((hasOpenTag && !hasCloseTag) || (!hasOpenTag && hasCloseTag)) { + if ((hasOpenTag && !hasCloseTag)) { console.warn("Partial block detected. Re-generating..."); continue; } - + + // If is present but is not, prepend + if (hasCloseTag && !hasOpenTag) { + res = '' + res; + } + // Changed this so if the model reasons, using and but doesn't start the message with , ges prepended to the message so no error occur. + // If both tags appear, remove them (and everything inside). if (hasOpenTag && hasCloseTag) { res = res.replace(/[\s\S]*?<\/think>/g, '');