@mastra/rag 2.7.2 → 2.7.3-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
@@ -4006,7 +4006,7 @@ var TextTransformer = class {
4006
4006
  };
4007
4007
  // src/document/transformers/character.ts
4008
4008
  function splitTextWithRegex(text, separator, separatorPosition) {
4009
- if (!separator) return text.split("");
4009
+ if (!separator) return Array.from(text);
4010
4010
  if (!text) return [];
4011
4011
  const result = [];
4012
4012
  let lastIndex = 0;
@@ -6217,6 +6217,14 @@ async function executeRerank({ results, query, scorer, options }) {
6217
6217
  });
6218
6218
  throw err;
6219
6219
  }
6220
+ if (!Number.isInteger(topK) || topK < 0) {
6221
+ const err = /* @__PURE__ */ new Error(`topK must be a nonnegative integer. Got ${topK}`);
6222
+ rerankSpan?.error({
6223
+ error: err,
6224
+ endSpan: true
6225
+ });
6226
+ throw err;
6227
+ }
6220
6228
  const resultLength = results.length;
6221
6229
  const queryAnalysis = queryEmbedding ? analyzeQueryEmbedding(queryEmbedding) : null;
6222
6230
  let scoredResults;
@@ -6750,15 +6758,8 @@ async function resolveVectorStore(options, context, logger) {
6750
6758
  if (mastra) return mastra.getVector(vectorStoreName);
6751
6759
  }
6752
6760
  function coerceTopK(topK, defaultValue = 10) {
6753
- if (typeof topK === "number") {
6754
- if (Number.isFinite(topK) && topK > 0) return topK;
6755
- return defaultValue;
6756
- }
6757
- if (typeof topK === "string") {
6758
- const parsed = Number(topK);
6759
- if (Number.isFinite(parsed) && parsed > 0) return parsed;
6760
- return defaultValue;
6761
- }
6761
+ const parsed = typeof topK === "string" ? Number(topK) : topK;
6762
+ if (typeof parsed === "number" && Number.isFinite(parsed) && Math.floor(parsed) >= 1) return Math.floor(parsed);
6762
6763
  return defaultValue;
6763
6764
  }
6764
6765
  function parseFilterValue(filter, logger) {