mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-17 12:45:39 +02:00
Update local.js
Fixed Local Model usage with reasoning
This commit is contained in:
parent
a245288cb2
commit
fd6ac47f07
1 changed files with 8 additions and 2 deletions
|
@ -51,11 +51,17 @@ export class Local {
|
||||||
const hasCloseTag = res.includes("</think>");
|
const hasCloseTag = res.includes("</think>");
|
||||||
|
|
||||||
// If there's a partial mismatch, retry to get a complete response.
|
// 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...");
|
console.warn("Partial <think> block detected. Re-generating...");
|
||||||
continue;
|
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 both tags appear, remove them (and everything inside).
|
||||||
if (hasOpenTag && hasCloseTag) {
|
if (hasOpenTag && hasCloseTag) {
|
||||||
res = res.replace(/<think>[\s\S]*?<\/think>/g, '');
|
res = res.replace(/<think>[\s\S]*?<\/think>/g, '');
|
||||||
|
|
Loading…
Add table
Reference in a new issue