ai 4.1.43 → 4.1.44
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -5793,17 +5793,19 @@ function getPotentialStartIndex(text2, searchedText) {
|
|
5793
5793
|
// core/middleware/extract-reasoning-middleware.ts
|
5794
5794
|
function extractReasoningMiddleware({
|
5795
5795
|
tagName,
|
5796
|
-
separator = "\n"
|
5796
|
+
separator = "\n",
|
5797
|
+
startWithReasoning = false
|
5797
5798
|
}) {
|
5798
5799
|
const openingTag = `<${tagName}>`;
|
5799
5800
|
const closingTag = `</${tagName}>`;
|
5800
5801
|
return {
|
5801
5802
|
middlewareVersion: "v1",
|
5802
5803
|
wrapGenerate: async ({ doGenerate }) => {
|
5803
|
-
const { text:
|
5804
|
-
if (
|
5805
|
-
return { text:
|
5804
|
+
const { text: rawText, ...rest } = await doGenerate();
|
5805
|
+
if (rawText == null) {
|
5806
|
+
return { text: rawText, ...rest };
|
5806
5807
|
}
|
5808
|
+
const text2 = startWithReasoning ? openingTag + rawText : rawText;
|
5807
5809
|
const regexp = new RegExp(`${openingTag}(.*?)${closingTag}`, "gs");
|
5808
5810
|
const matches = Array.from(text2.matchAll(regexp));
|
5809
5811
|
if (!matches.length) {
|
@@ -5826,7 +5828,7 @@ function extractReasoningMiddleware({
|
|
5826
5828
|
let isFirstReasoning = true;
|
5827
5829
|
let isFirstText = true;
|
5828
5830
|
let afterSwitch = false;
|
5829
|
-
let isReasoning =
|
5831
|
+
let isReasoning = startWithReasoning;
|
5830
5832
|
let buffer = "";
|
5831
5833
|
return {
|
5832
5834
|
stream: stream.pipeThrough(
|