@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.mjs
CHANGED
|
@@ -1454,20 +1454,28 @@ var getFriendlyError = (err) => {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
};
|
|
1456
1456
|
function parseThinking(text) {
|
|
1457
|
-
const
|
|
1458
|
-
|
|
1459
|
-
const openIdx = text.indexOf(openTag);
|
|
1460
|
-
if (openIdx === -1) {
|
|
1457
|
+
const openMatch = text.match(/<\s*thinking\s*>/i);
|
|
1458
|
+
if (!openMatch) {
|
|
1461
1459
|
return { thinking: "", content: text, isComplete: true };
|
|
1462
1460
|
}
|
|
1463
|
-
const
|
|
1464
|
-
const
|
|
1465
|
-
|
|
1466
|
-
|
|
1461
|
+
const openIdx = openMatch.index ?? 0;
|
|
1462
|
+
const openTagLength = openMatch[0].length;
|
|
1463
|
+
const start = openIdx + openTagLength;
|
|
1464
|
+
const contentBefore = text.slice(0, openIdx);
|
|
1465
|
+
const textAfterOpen = text.slice(start);
|
|
1466
|
+
const closeMatch = textAfterOpen.match(/<\/\s*thinking\s*>/i);
|
|
1467
|
+
if (!closeMatch) {
|
|
1468
|
+
return {
|
|
1469
|
+
thinking: textAfterOpen,
|
|
1470
|
+
content: contentBefore,
|
|
1471
|
+
isComplete: false
|
|
1472
|
+
};
|
|
1467
1473
|
}
|
|
1474
|
+
const closeIdx = closeMatch.index ?? 0;
|
|
1475
|
+
const closeTagLength = closeMatch[0].length;
|
|
1468
1476
|
return {
|
|
1469
|
-
thinking:
|
|
1470
|
-
content:
|
|
1477
|
+
thinking: textAfterOpen.slice(0, closeIdx),
|
|
1478
|
+
content: contentBefore + textAfterOpen.slice(closeIdx + closeTagLength),
|
|
1471
1479
|
isComplete: true
|
|
1472
1480
|
};
|
|
1473
1481
|
}
|