@akropolys/kiku 1.5.7 → 1.5.8
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/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1489,20 +1489,28 @@ var getFriendlyError = (err) => {
|
|
|
1489
1489
|
}
|
|
1490
1490
|
};
|
|
1491
1491
|
function parseThinking(text) {
|
|
1492
|
-
const
|
|
1493
|
-
|
|
1494
|
-
const openIdx = text.indexOf(openTag);
|
|
1495
|
-
if (openIdx === -1) {
|
|
1492
|
+
const openMatch = text.match(/<\s*thinking\s*>/i);
|
|
1493
|
+
if (!openMatch) {
|
|
1496
1494
|
return { thinking: "", content: text, isComplete: true };
|
|
1497
1495
|
}
|
|
1498
|
-
const
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1501
|
-
|
|
1496
|
+
const openIdx = openMatch.index ?? 0;
|
|
1497
|
+
const openTagLength = openMatch[0].length;
|
|
1498
|
+
const start = openIdx + openTagLength;
|
|
1499
|
+
const contentBefore = text.slice(0, openIdx);
|
|
1500
|
+
const textAfterOpen = text.slice(start);
|
|
1501
|
+
const closeMatch = textAfterOpen.match(/<\/\s*thinking\s*>/i);
|
|
1502
|
+
if (!closeMatch) {
|
|
1503
|
+
return {
|
|
1504
|
+
thinking: textAfterOpen,
|
|
1505
|
+
content: contentBefore,
|
|
1506
|
+
isComplete: false
|
|
1507
|
+
};
|
|
1502
1508
|
}
|
|
1509
|
+
const closeIdx = closeMatch.index ?? 0;
|
|
1510
|
+
const closeTagLength = closeMatch[0].length;
|
|
1503
1511
|
return {
|
|
1504
|
-
thinking:
|
|
1505
|
-
content:
|
|
1512
|
+
thinking: textAfterOpen.slice(0, closeIdx),
|
|
1513
|
+
content: contentBefore + textAfterOpen.slice(closeIdx + closeTagLength),
|
|
1506
1514
|
isComplete: true
|
|
1507
1515
|
};
|
|
1508
1516
|
}
|