@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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-rag-graph-rag.md +1 -1
- package/dist/docs/references/reference-tools-document-chunker-tool.md +8 -8
- package/dist/docs/references/reference-tools-vector-query-tool.md +4 -4
- package/dist/document/transformers/text.d.ts.map +1 -1
- package/dist/index.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
package/dist/docs/SKILL.md
CHANGED
|
@@ -83,7 +83,7 @@ Returns an array of `RankedNode` objects, where each node contains:
|
|
|
83
83
|
|
|
84
84
|
**content** (`string`): Text content of the document chunk
|
|
85
85
|
|
|
86
|
-
**metadata** (`Record<string, any>`): Additional metadata associated with the chunk
|
|
86
|
+
**metadata** (`Record<string, any>`): Additional metadata associated with the chunk, when present
|
|
87
87
|
|
|
88
88
|
**score** (`number`): Combined relevance score from graph traversal
|
|
89
89
|
|
|
@@ -20,9 +20,9 @@ const chunker = createDocumentChunkerTool({
|
|
|
20
20
|
doc: document,
|
|
21
21
|
params: {
|
|
22
22
|
strategy: 'recursive',
|
|
23
|
-
|
|
23
|
+
maxSize: 512,
|
|
24
24
|
overlap: 50,
|
|
25
|
-
|
|
25
|
+
separators: ['\n'],
|
|
26
26
|
},
|
|
27
27
|
})
|
|
28
28
|
|
|
@@ -39,11 +39,11 @@ const { chunks } = await chunker.execute()
|
|
|
39
39
|
|
|
40
40
|
**strategy** (`'recursive'`): The chunking strategy to use (Default: `'recursive'`)
|
|
41
41
|
|
|
42
|
-
**
|
|
42
|
+
**maxSize** (`number`): Maximum size of each chunk in tokens/characters (Default: `512`)
|
|
43
43
|
|
|
44
44
|
**overlap** (`number`): Number of overlapping tokens/characters between chunks (Default: `50`)
|
|
45
45
|
|
|
46
|
-
**
|
|
46
|
+
**separators** (`string[]`): Separators to split on, in order of priority (recursive strategy) (Default: `['\n']`)
|
|
47
47
|
|
|
48
48
|
## Returns
|
|
49
49
|
|
|
@@ -64,9 +64,9 @@ const chunker = createDocumentChunkerTool({
|
|
|
64
64
|
doc: technicalDoc,
|
|
65
65
|
params: {
|
|
66
66
|
strategy: 'recursive',
|
|
67
|
-
|
|
67
|
+
maxSize: 1024, // Larger chunks
|
|
68
68
|
overlap: 100, // More overlap
|
|
69
|
-
|
|
69
|
+
separators: ['\n\n'], // Split on double newlines
|
|
70
70
|
},
|
|
71
71
|
})
|
|
72
72
|
|
|
@@ -82,8 +82,8 @@ chunks.forEach((chunk, index) => {
|
|
|
82
82
|
|
|
83
83
|
The chunker is created as a Mastra tool with the following properties:
|
|
84
84
|
|
|
85
|
-
- **Tool ID**: `Document Chunker {strategy} {
|
|
86
|
-
- **Description**: `Chunks document using {strategy} strategy with
|
|
85
|
+
- **Tool ID**: `Document Chunker {strategy} {maxSize}`
|
|
86
|
+
- **Description**: `Chunks document using {strategy} strategy with maxSize {maxSize} and {overlap} overlap`
|
|
87
87
|
- **Input Schema**: Empty object (no additional inputs required)
|
|
88
88
|
- **Output Schema**: Object containing the chunks array
|
|
89
89
|
|
|
@@ -21,13 +21,13 @@ const queryTool = createVectorQueryTool({
|
|
|
21
21
|
|
|
22
22
|
## Parameters
|
|
23
23
|
|
|
24
|
-
> **Note:** **Parameter Requirements:** Most fields can be set at creation as defaults. Some fields can be overridden at runtime via the request context or input. If a required field is missing from both creation and runtime, an error will be thrown. Note that `
|
|
24
|
+
> **Note:** **Parameter Requirements:** Most fields can be set at creation as defaults. Some fields can be overridden at runtime via the request context or input. If a required field is missing from both creation and runtime, an error will be thrown. Note that `id` and `description` can only be set at creation time.
|
|
25
25
|
|
|
26
|
-
**id** (`string`): Custom ID for the tool. By default: 'VectorQuery {vectorStoreName} {indexName} Tool'. (Set at creation only.)
|
|
26
|
+
**id** (`string`): Custom ID for the tool. By default: 'VectorQuery {vectorStoreName} {indexName} Tool', where {vectorStoreName} is 'DirectVectorStore' when a vectorStore instance is passed without a vectorStoreName. (Set at creation only.)
|
|
27
27
|
|
|
28
28
|
**description** (`string`): Custom description for the tool. By default: 'Access the knowledge base to find information needed to answer user questions' (Set at creation only.)
|
|
29
29
|
|
|
30
|
-
**model** (`EmbeddingModel`): Embedding model to use for vector search. (
|
|
30
|
+
**model** (`EmbeddingModel`): Embedding model to use for vector search. (Can be set at creation or overridden at runtime via the request context.)
|
|
31
31
|
|
|
32
32
|
**vectorStoreName** (`string`): Name of the vector store to query. (Can be set at creation or overridden at runtime.)
|
|
33
33
|
|
|
@@ -47,7 +47,7 @@ const queryTool = createVectorQueryTool({
|
|
|
47
47
|
|
|
48
48
|
**reranker.options.weights** (`WeightConfig`): Weights for scoring components (semantic: 0.4, vector: 0.4, position: 0.2)
|
|
49
49
|
|
|
50
|
-
**reranker.options.topK** (`number`): Number of top results to return
|
|
50
|
+
**reranker.options.topK** (`number`): Number of top results to return after reranking. Falls back to the query's topK (from the request context, the tool input, or 10) when unset or 0.
|
|
51
51
|
|
|
52
52
|
**databaseConfig** (`DatabaseConfig`): Database-specific configuration options for optimizing queries. (Can be set at creation or overridden at runtime.)
|
|
53
53
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/document/transformers/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,8BAAsB,eAAgB,YAAW,WAAW;IAC1D,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KA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B,aAAqB,EACrB,eAAsB,GACvB,EAAE,gBAAgB,EAUlB;IAED,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAErC;IAED,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE,CAAC;IAEzD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,QAAQ,EAAE,CAoC9E;IAED,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAQhD;IAED,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAUpD;IAED,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnE;IAED;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAkFvF;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -644,7 +644,7 @@ let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
|
644
644
|
};
|
|
645
645
|
};
|
|
646
646
|
//#endregion
|
|
647
|
-
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider-utils/2.2.8/
|
|
647
|
+
//#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
|
|
648
648
|
var import_secure_json_parse = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
649
649
|
const hasBuffer = typeof Buffer !== "undefined";
|
|
650
650
|
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
@@ -1187,7 +1187,7 @@ function withoutTrailingSlash(url) {
|
|
|
1187
1187
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
1188
1188
|
}
|
|
1189
1189
|
//#endregion
|
|
1190
|
-
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/openai/1.3.24/
|
|
1190
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/openai/1.3.24/9ea9437756f1191484449f4e611ce2befb4ff9a7be92f5dfa8b1970d80a87966/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
1191
1191
|
function convertToOpenAIChatMessages({ prompt, useLegacyFunctionCalling = false, systemMessageMode = "system" }) {
|
|
1192
1192
|
const messages = [];
|
|
1193
1193
|
const warnings = [];
|
|
@@ -3921,13 +3921,19 @@ var TextTransformer = class {
|
|
|
3921
3921
|
texts.forEach((text, i) => {
|
|
3922
3922
|
let index = 0;
|
|
3923
3923
|
let previousChunkLen = 0;
|
|
3924
|
+
let previousIndex = -1;
|
|
3924
3925
|
this.splitText({ text }).forEach((chunk) => {
|
|
3925
3926
|
const metadata = { ..._metadatas[i] };
|
|
3926
3927
|
if (this.addStartIndex) {
|
|
3927
3928
|
const offset = index + previousChunkLen - this.overlap;
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3929
|
+
let found = text.indexOf(chunk, Math.max(0, offset));
|
|
3930
|
+
if (found === -1) found = text.indexOf(chunk, previousIndex + 1);
|
|
3931
|
+
metadata.startIndex = found;
|
|
3932
|
+
if (found !== -1) {
|
|
3933
|
+
index = found;
|
|
3934
|
+
previousIndex = found;
|
|
3935
|
+
previousChunkLen = chunk.length;
|
|
3936
|
+
}
|
|
3931
3937
|
}
|
|
3932
3938
|
documents.push(new Document({
|
|
3933
3939
|
text: chunk,
|