@mastra/rag 2.6.7 → 2.6.8-alpha.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/dist/index.js CHANGED
@@ -642,7 +642,7 @@ let customAlphabet = (alphabet, defaultSize = 21) => {
642
642
  };
643
643
  };
644
644
  //#endregion
645
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider-utils/2.2.8/fd79a5c5f5d36120acbfd746754884c17798c35178b46bd11cca9dff89c013d2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
645
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider-utils/2.2.8/b5ebb650c869d075671e49b164b6e4defe8f9652b8a95fc120ecfeb885936b4f/node_modules/@ai-sdk/provider-utils/dist/index.mjs
646
646
  var import_secure_json_parse = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
647
647
  const hasBuffer = typeof Buffer !== "undefined";
648
648
  const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
@@ -1185,7 +1185,7 @@ function withoutTrailingSlash(url) {
1185
1185
  return url == null ? void 0 : url.replace(/\/$/, "");
1186
1186
  }
1187
1187
  //#endregion
1188
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/openai/1.3.24/016fac41d998ff168d98fde7926aa7713f8ffc38160a6b4427bfdc41fae1bc99/node_modules/@ai-sdk/openai/dist/index.mjs
1188
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/openai/1.3.24/9ea9437756f1191484449f4e611ce2befb4ff9a7be92f5dfa8b1970d80a87966/node_modules/@ai-sdk/openai/dist/index.mjs
1189
1189
  function convertToOpenAIChatMessages({ prompt, useLegacyFunctionCalling = false, systemMessageMode = "system" }) {
1190
1190
  const messages = [];
1191
1191
  const warnings = [];
@@ -3919,13 +3919,19 @@ var TextTransformer = class {
3919
3919
  texts.forEach((text, i) => {
3920
3920
  let index = 0;
3921
3921
  let previousChunkLen = 0;
3922
+ let previousIndex = -1;
3922
3923
  this.splitText({ text }).forEach((chunk) => {
3923
3924
  const metadata = { ..._metadatas[i] };
3924
3925
  if (this.addStartIndex) {
3925
3926
  const offset = index + previousChunkLen - this.overlap;
3926
- index = text.indexOf(chunk, Math.max(0, offset));
3927
- metadata.startIndex = index;
3928
- previousChunkLen = chunk.length;
3927
+ let found = text.indexOf(chunk, Math.max(0, offset));
3928
+ if (found === -1) found = text.indexOf(chunk, previousIndex + 1);
3929
+ metadata.startIndex = found;
3930
+ if (found !== -1) {
3931
+ index = found;
3932
+ previousIndex = found;
3933
+ previousChunkLen = chunk.length;
3934
+ }
3929
3935
  }
3930
3936
  documents.push(new Document({
3931
3937
  text: chunk,