mioku-plugin-chat 2.10.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/chat-engine.ts +9 -26
- package/package.json +1 -1
package/core/chat-engine.ts
CHANGED
|
@@ -721,7 +721,6 @@ function cleanMarkers(text: string): string {
|
|
|
721
721
|
let cleaned = stripThinkBlocks(text).trim();
|
|
722
722
|
|
|
723
723
|
cleaned = cleaned
|
|
724
|
-
.replace(/<Ai>\s*<think>[\s\S]*?<\/Ai>/gi, "")
|
|
725
724
|
.replace(/<||DSML||tool_calls>[\s\S]*?<\/||DSML||tool_calls>/gi, "")
|
|
726
725
|
.replace(/<||DSML||invoke[^>]*>[\s\S]*?<\/||DSML||invoke>/gi, "")
|
|
727
726
|
.replace(
|
|
@@ -824,7 +823,7 @@ function stripThinkBlocks(text: string): string {
|
|
|
824
823
|
source = afterOpen.slice(close.end);
|
|
825
824
|
}
|
|
826
825
|
|
|
827
|
-
return output.replace(
|
|
826
|
+
return output.replace(/<\/?(?:think|thinking)\s*>/gi, "");
|
|
828
827
|
}
|
|
829
828
|
|
|
830
829
|
function createThinkTagStreamFilter() {
|
|
@@ -840,7 +839,7 @@ function createThinkTagStreamFilter() {
|
|
|
840
839
|
if (insideThink) {
|
|
841
840
|
const close = findThinkCloseTag(buffer);
|
|
842
841
|
if (!close) {
|
|
843
|
-
buffer = force ? "" : keepTagPrefixSuffix(buffer, "</
|
|
842
|
+
buffer = force ? "" : keepTagPrefixSuffix(buffer, "</thinking>");
|
|
844
843
|
break;
|
|
845
844
|
}
|
|
846
845
|
|
|
@@ -851,7 +850,7 @@ function createThinkTagStreamFilter() {
|
|
|
851
850
|
|
|
852
851
|
const open = findThinkOpenTag(buffer);
|
|
853
852
|
if (!open) {
|
|
854
|
-
const keep = force ? "" : keepTagPrefixSuffix(buffer, "<
|
|
853
|
+
const keep = force ? "" : keepTagPrefixSuffix(buffer, "<thinking>");
|
|
855
854
|
output += buffer.slice(0, buffer.length - keep.length);
|
|
856
855
|
buffer = keep;
|
|
857
856
|
break;
|
|
@@ -862,38 +861,22 @@ function createThinkTagStreamFilter() {
|
|
|
862
861
|
insideThink = true;
|
|
863
862
|
}
|
|
864
863
|
|
|
865
|
-
return output.replace(
|
|
864
|
+
return output.replace(/<\/?(?:think|thinking)\s*>/gi, "");
|
|
866
865
|
},
|
|
867
866
|
};
|
|
868
867
|
}
|
|
869
868
|
|
|
870
869
|
function findThinkOpenTag(text: string): { index: number; end: number } | null {
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
const afterName = text[index + "<think".length];
|
|
878
|
-
if (afterName && !/[\s>]/.test(afterName)) {
|
|
879
|
-
const next = findThinkOpenTag(text.slice(index + 1));
|
|
880
|
-
return next
|
|
881
|
-
? { index: index + 1 + next.index, end: index + 1 + next.end }
|
|
882
|
-
: null;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
const closeIndex = text.indexOf(">", index + "<think".length);
|
|
886
|
-
if (closeIndex < 0) {
|
|
887
|
-
return { index, end: text.length };
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
return { index, end: closeIndex + 1 };
|
|
870
|
+
const match = /<(think|thinking)\b[^>]*>/i.exec(text);
|
|
871
|
+
return match
|
|
872
|
+
? { index: match.index, end: match.index + match[0].length }
|
|
873
|
+
: null;
|
|
891
874
|
}
|
|
892
875
|
|
|
893
876
|
function findThinkCloseTag(
|
|
894
877
|
text: string,
|
|
895
878
|
): { index: number; end: number } | null {
|
|
896
|
-
const match = /<\/think\s*>/i.exec(text);
|
|
879
|
+
const match = /<\/(think|thinking)\s*>/i.exec(text);
|
|
897
880
|
return match
|
|
898
881
|
? { index: match.index, end: match.index + match[0].length }
|
|
899
882
|
: null;
|