@mastra/rag 2.0.0-beta.1 → 2.0.0-beta.3
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 +94 -0
- package/dist/document/document.d.ts.map +1 -1
- package/dist/document/transformers/html.d.ts +1 -0
- package/dist/document/transformers/html.d.ts.map +1 -1
- package/dist/document/transformers/markdown.d.ts.map +1 -1
- package/dist/graph-rag/index.d.ts +13 -2
- package/dist/graph-rag/index.d.ts.map +1 -1
- package/dist/index.cjs +86 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +86 -19
- package/dist/index.js.map +1 -1
- package/dist/tools/graph-rag.d.ts.map +1 -1
- package/dist/tools/vector-query.d.ts.map +1 -1
- package/dist/utils/convert-sources.d.ts +3 -1
- package/dist/utils/convert-sources.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# @mastra/rag
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add maxSize support for HTML chunking strategies ([#10654](https://github.com/mastra-ai/mastra/pull/10654))
|
|
8
|
+
|
|
9
|
+
Added support for the `maxSize` option in HTML chunking strategies (`headers` and `sections`), allowing users to control the maximum chunk size when chunking HTML documents. Previously, HTML chunks could be excessively large when sections contained substantial content.
|
|
10
|
+
|
|
11
|
+
**Changes:**
|
|
12
|
+
- Added `maxSize` support to `headers` strategy - applies `RecursiveCharacterTransformer` after header-based splitting
|
|
13
|
+
- Added `maxSize` support to `sections` strategy - applies `RecursiveCharacterTransformer` after section-based splitting
|
|
14
|
+
- Fixed `splitHtmlByHeaders` content extraction bug - changed from broken `nextElementSibling` to working `parentNode.childNodes` approach
|
|
15
|
+
- Added comprehensive test coverage including integration test with real arXiv paper
|
|
16
|
+
|
|
17
|
+
**Usage:**
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { MDocument } from '@mastra/rag';
|
|
21
|
+
|
|
22
|
+
const doc = MDocument.fromHTML(htmlContent);
|
|
23
|
+
|
|
24
|
+
const chunks = await doc.chunk({
|
|
25
|
+
strategy: 'html',
|
|
26
|
+
headers: [
|
|
27
|
+
['h1', 'Header 1'],
|
|
28
|
+
['h2', 'Header 2'],
|
|
29
|
+
['h3', 'Header 3'],
|
|
30
|
+
],
|
|
31
|
+
maxSize: 512, // Control chunk size
|
|
32
|
+
overlap: 50, // Optional overlap for context
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Results from real arXiv paper test:**
|
|
37
|
+
- Without maxSize: 22 chunks, max 45,531 chars (too big!)
|
|
38
|
+
- With maxSize=512: 499 chunks, max 512 chars (properly sized)
|
|
39
|
+
|
|
40
|
+
Fixes #7942
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
|
|
43
|
+
- @mastra/core@1.0.0-beta.6
|
|
44
|
+
|
|
45
|
+
## 2.0.0-beta.2
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Add table support to markdown transformer ([#10487](https://github.com/mastra-ai/mastra/pull/10487))
|
|
50
|
+
|
|
51
|
+
Added support for markdown tables in the `MarkdownHeaderTransformer` to prevent tables from being split in the middle during document chunking. Tables are now treated as semantic units similar to code blocks.
|
|
52
|
+
|
|
53
|
+
**Changes:**
|
|
54
|
+
- Updated `MarkdownHeaderTransformer` to detect and preserve markdown tables during chunking
|
|
55
|
+
- Tables are identified by lines containing pipe characters (`|`)
|
|
56
|
+
- Tables are kept together as a single block, preventing splits that would break table structure
|
|
57
|
+
- Added comprehensive test coverage for table handling in various scenarios
|
|
58
|
+
- Works with both simple and complex tables, including multi-row tables and tables with different formatting
|
|
59
|
+
|
|
60
|
+
**Usage:**
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { MDocument } from '@mastra/rag';
|
|
64
|
+
|
|
65
|
+
const doc = MDocument.fromMarkdown(`
|
|
66
|
+
# Data Report
|
|
67
|
+
|
|
68
|
+
## Results
|
|
69
|
+
|
|
70
|
+
| Name | Score | Status |
|
|
71
|
+
|------|-------|--------|
|
|
72
|
+
| Alice | 95 | Pass |
|
|
73
|
+
| Bob | 87 | Pass |
|
|
74
|
+
| Carol | 78 | Pass |
|
|
75
|
+
|
|
76
|
+
## Summary
|
|
77
|
+
|
|
78
|
+
The results show...
|
|
79
|
+
`);
|
|
80
|
+
|
|
81
|
+
const chunks = await doc.chunk({
|
|
82
|
+
strategy: 'markdown',
|
|
83
|
+
headers: [
|
|
84
|
+
['#', 'title'],
|
|
85
|
+
['##', 'section'],
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Tables will now be preserved intact within chunks
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- Fix invalid filter handling in vector queries and graph-rag searches. Invalid filter inputs now throw explicit errors instead of silently falling back to empty filters, preventing unintended unfiltered results. ([#10375](https://github.com/mastra-ai/mastra/pull/10375))
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [[`21a15de`](https://github.com/mastra-ai/mastra/commit/21a15de369fe82aac26bb642ed7be73505475e8b), [`feb7ee4`](https://github.com/mastra-ai/mastra/commit/feb7ee4d09a75edb46c6669a3beaceec78811747), [`b0e2ea5`](https://github.com/mastra-ai/mastra/commit/b0e2ea5b52c40fae438b9e2f7baee6f0f89c5442), [`c456e01`](https://github.com/mastra-ai/mastra/commit/c456e0149e3c176afcefdbd9bb1d2c5917723725), [`ab035c2`](https://github.com/mastra-ai/mastra/commit/ab035c2ef6d8cc7bb25f06f1a38508bd9e6f126b), [`1a46a56`](https://github.com/mastra-ai/mastra/commit/1a46a566f45a3fcbadc1cf36bf86d351f264bfa3), [`3cf540b`](https://github.com/mastra-ai/mastra/commit/3cf540b9fbfea8f4fc8d3a2319a4e6c0b0cbfd52), [`1c6ce51`](https://github.com/mastra-ai/mastra/commit/1c6ce51f875915ab57fd36873623013699a2a65d), [`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f), [`a97003a`](https://github.com/mastra-ai/mastra/commit/a97003aa1cf2f4022a41912324a1e77263b326b8), [`ccc141e`](https://github.com/mastra-ai/mastra/commit/ccc141ed27da0abc3a3fc28e9e5128152e8e37f4), [`fe3b897`](https://github.com/mastra-ai/mastra/commit/fe3b897c2ccbcd2b10e81b099438c7337feddf89), [`00123ba`](https://github.com/mastra-ai/mastra/commit/00123ba96dc9e5cd0b110420ebdba56d8f237b25), [`29c4309`](https://github.com/mastra-ai/mastra/commit/29c4309f818b24304c041bcb4a8f19b5f13f6b62), [`16785ce`](https://github.com/mastra-ai/mastra/commit/16785ced928f6f22638f4488cf8a125d99211799), [`de8239b`](https://github.com/mastra-ai/mastra/commit/de8239bdcb1d8c0cfa06da21f1569912a66bbc8a), [`b5e6cd7`](https://github.com/mastra-ai/mastra/commit/b5e6cd77fc8c8e64e0494c1d06cee3d84e795d1e), [`3759cb0`](https://github.com/mastra-ai/mastra/commit/3759cb064935b5f74c65ac2f52a1145f7352899d), [`651e772`](https://github.com/mastra-ai/mastra/commit/651e772eb1475fb13e126d3fcc01751297a88214), [`b61b93f`](https://github.com/mastra-ai/mastra/commit/b61b93f9e058b11dd2eec169853175d31dbdd567), [`bae33d9`](https://github.com/mastra-ai/mastra/commit/bae33d91a63fbb64d1e80519e1fc1acaed1e9013), [`c0b731f`](https://github.com/mastra-ai/mastra/commit/c0b731fb27d712dc8582e846df5c0332a6a0c5ba), [`43ca8f2`](https://github.com/mastra-ai/mastra/commit/43ca8f2c7334851cc7b4d3d2f037d8784bfbdd5f), [`2ca67cc`](https://github.com/mastra-ai/mastra/commit/2ca67cc3bb1f6a617353fdcab197d9efebe60d6f), [`9e67002`](https://github.com/mastra-ai/mastra/commit/9e67002b52c9be19936c420a489dbee9c5fd6a78), [`35edc49`](https://github.com/mastra-ai/mastra/commit/35edc49ac0556db609189641d6341e76771b81fc)]:
|
|
95
|
+
- @mastra/core@1.0.0-beta.5
|
|
96
|
+
|
|
3
97
|
## 2.0.0-beta.1
|
|
4
98
|
|
|
5
99
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/document/document.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAgC,MAAM,UAAU,CAAC;AAU3E,OAAO,KAAK,EACV,WAAW,EAEX,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAGjB,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,IAAI,CAAS;gBAET,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;SAAE,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAOhG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC;IAmDjG,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS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AE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtD,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAa5D,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB5D,qBAAqB,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC;IAU5E,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAiBnD,OAAO,IAAI,KAAK,EAAE;IAIlB,OAAO,IAAI,MAAM,EAAE;IAInB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;CAGrC"}
|
|
@@ -23,6 +23,7 @@ export declare class HTMLSectionTransformer {
|
|
|
23
23
|
});
|
|
24
24
|
splitText(text: string): Document[];
|
|
25
25
|
private getXPath;
|
|
26
|
+
private getTextContent;
|
|
26
27
|
private splitHtmlByHeaders;
|
|
27
28
|
splitDocuments(documents: Document[]): Promise<Document[]>;
|
|
28
29
|
createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/document/transformers/html.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAWjD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,iBAAiB,CAAU;gBAEvB,OAAO,EAAE,gBAAgB,GAAG;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;KAAE;IAKvE,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ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MAAM,CAAC,EAAE,EAAE,cAAc,GAAE,OAAe,EAAE,YAAY,GAAE,OAAc;IAM/G,OAAO,CAAC,sBAAsB;IAuD9B,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/document/transformers/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAa5D,qBAAa,mBAAoB,SAAQ,6BAA6B;gBACxD,OAAO,GAAE,gBAAqB;CAI3C;AAED,qBAAa,yBAAyB;IACpC,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,YAAY,CAAU;gBAElB,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,cAAc,GAAE,OAAe,EAAE,YAAY,GAAE,OAAc;IAM/G,OAAO,CAAC,sBAAsB;IAuD9B,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ,EAAE;IAsIjD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,QAAQ,EAAE;IAmB/E,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE;CAWtD"}
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
* - Improve graph traversal and querying using types
|
|
7
7
|
*/
|
|
8
8
|
type SupportedEdgeType = 'semantic';
|
|
9
|
+
type GraphMetadata = Record<string, any>;
|
|
9
10
|
export interface GraphNode {
|
|
10
11
|
id: string;
|
|
11
12
|
content: string;
|
|
12
13
|
embedding?: number[];
|
|
13
|
-
metadata?:
|
|
14
|
+
metadata?: GraphMetadata;
|
|
14
15
|
}
|
|
15
16
|
export interface RankedNode extends GraphNode {
|
|
16
17
|
score: number;
|
|
@@ -46,11 +47,21 @@ export declare class GraphRAG {
|
|
|
46
47
|
createGraph(chunks: GraphChunk[], embeddings: GraphEmbedding[]): void;
|
|
47
48
|
private selectWeightedNeighbor;
|
|
48
49
|
private randomWalkWithRestart;
|
|
49
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Query the graph with a dense embedding and optional metadata filter.
|
|
52
|
+
*
|
|
53
|
+
* @param query - The embedding vector to query.
|
|
54
|
+
* @param topK - Number of top results to return.
|
|
55
|
+
* @param randomWalkSteps - Steps for random walk reranking.
|
|
56
|
+
* @param restartProb - Restart probability for random walk.
|
|
57
|
+
* @param filter - Optional strict metadata filter. All key-value pairs must match exactly.
|
|
58
|
+
*/
|
|
59
|
+
query({ query, topK, randomWalkSteps, restartProb, filter, }: {
|
|
50
60
|
query: number[];
|
|
51
61
|
topK?: number;
|
|
52
62
|
randomWalkSteps?: number;
|
|
53
63
|
restartProb?: number;
|
|
64
|
+
filter?: Partial<GraphMetadata>;
|
|
54
65
|
}): RankedNode[];
|
|
55
66
|
}
|
|
56
67
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graph-rag/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graph-rag/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,KAAK,iBAAiB,GAAG,UAAU,CAAC;AACpC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAGzC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,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AAK,CAAC,EACJ,KAAK,EACL,IAAS,EACT,eAAqB,EACrB,WAAkB,EAClB,MAAM,GACP,EAAE;QACD,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;KACjC,GAAG,UAAU,EAAE;CA+DjB"}
|
package/dist/index.cjs
CHANGED
|
@@ -272,7 +272,7 @@ Provide keywords in the following comma-separated format: 'KEYWORDS: <keywords>'
|
|
|
272
272
|
var defaultQuestionExtractPrompt = new PromptTemplate({
|
|
273
273
|
templateVars: ["numQuestions", "context"],
|
|
274
274
|
template: `(
|
|
275
|
-
"Given the contextual
|
|
275
|
+
"Given the contextual information below, generate {numQuestions} questions this context can provide specific answers to which are unlikely to be found elsewhere. Higher-level summaries of surrounding context may be provided as well. "
|
|
276
276
|
"Try using these summaries to generate better questions that this context can answer."
|
|
277
277
|
"---------------------"
|
|
278
278
|
"{context}"
|
|
@@ -4999,23 +4999,47 @@ var HTMLSectionTransformer = class {
|
|
|
4999
4999
|
}
|
|
5000
5000
|
return "/" + parts.join("/");
|
|
5001
5001
|
}
|
|
5002
|
+
getTextContent(element) {
|
|
5003
|
+
if (!element) return "";
|
|
5004
|
+
if (!element.tagName) {
|
|
5005
|
+
return element.text || "";
|
|
5006
|
+
}
|
|
5007
|
+
let content = element.text || "";
|
|
5008
|
+
if (element.childNodes) {
|
|
5009
|
+
for (const child of element.childNodes) {
|
|
5010
|
+
const childText = this.getTextContent(child);
|
|
5011
|
+
if (childText) {
|
|
5012
|
+
content += " " + childText;
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
return content.trim();
|
|
5017
|
+
}
|
|
5002
5018
|
splitHtmlByHeaders(htmlDoc) {
|
|
5003
5019
|
const sections = [];
|
|
5004
5020
|
const root = nodeHtmlBetterParser.parse(htmlDoc);
|
|
5005
5021
|
const headers = Object.keys(this.headersToSplitOn);
|
|
5006
5022
|
const headerElements = root.querySelectorAll(headers.join(","));
|
|
5007
|
-
headerElements.forEach((headerElement
|
|
5023
|
+
headerElements.forEach((headerElement) => {
|
|
5008
5024
|
const header = headerElement.text?.trim() || "";
|
|
5009
5025
|
const tagName = headerElement.tagName;
|
|
5010
5026
|
const xpath = this.getXPath(headerElement);
|
|
5011
5027
|
let content = "";
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5028
|
+
const parentNode = headerElement.parentNode;
|
|
5029
|
+
if (parentNode && parentNode.childNodes) {
|
|
5030
|
+
let foundHeader = false;
|
|
5031
|
+
for (const node of parentNode.childNodes) {
|
|
5032
|
+
if (node === headerElement) {
|
|
5033
|
+
foundHeader = true;
|
|
5034
|
+
continue;
|
|
5035
|
+
}
|
|
5036
|
+
if (foundHeader && node.tagName && headers.includes(node.tagName.toLowerCase())) {
|
|
5037
|
+
break;
|
|
5038
|
+
}
|
|
5039
|
+
if (foundHeader) {
|
|
5040
|
+
content += this.getTextContent(node) + " ";
|
|
5041
|
+
}
|
|
5017
5042
|
}
|
|
5018
|
-
currentElement = currentElement.nextElementSibling;
|
|
5019
5043
|
}
|
|
5020
5044
|
content = content.trim();
|
|
5021
5045
|
sections.push({
|
|
@@ -5567,6 +5591,11 @@ var MarkdownHeaderTransformer = class {
|
|
|
5567
5591
|
currentContent.push(line);
|
|
5568
5592
|
continue;
|
|
5569
5593
|
}
|
|
5594
|
+
const isTableLine = strippedLine.includes("|") && strippedLine.length > 0;
|
|
5595
|
+
if (isTableLine) {
|
|
5596
|
+
currentContent.push(line);
|
|
5597
|
+
continue;
|
|
5598
|
+
}
|
|
5570
5599
|
let headerMatched = false;
|
|
5571
5600
|
for (const [sep, name14] of this.headersToSplitOn) {
|
|
5572
5601
|
if (strippedLine.startsWith(sep) && (strippedLine.length === sep.length || strippedLine[sep.length] === " ")) {
|
|
@@ -6387,13 +6416,33 @@ var MDocument = class _MDocument {
|
|
|
6387
6416
|
async chunkHTML(options) {
|
|
6388
6417
|
if (options?.headers?.length) {
|
|
6389
6418
|
const rt = new HTMLHeaderTransformer(options);
|
|
6390
|
-
|
|
6419
|
+
let textSplit = rt.transformDocuments(this.chunks);
|
|
6420
|
+
if (options?.maxSize) {
|
|
6421
|
+
const textSplitter = new RecursiveCharacterTransformer({
|
|
6422
|
+
maxSize: options.maxSize,
|
|
6423
|
+
overlap: options.overlap,
|
|
6424
|
+
keepSeparator: options.keepSeparator,
|
|
6425
|
+
addStartIndex: options.addStartIndex,
|
|
6426
|
+
stripWhitespace: options.stripWhitespace
|
|
6427
|
+
});
|
|
6428
|
+
textSplit = textSplitter.splitDocuments(textSplit);
|
|
6429
|
+
}
|
|
6391
6430
|
this.chunks = textSplit;
|
|
6392
6431
|
return;
|
|
6393
6432
|
}
|
|
6394
6433
|
if (options?.sections?.length) {
|
|
6395
6434
|
const rt = new HTMLSectionTransformer(options);
|
|
6396
|
-
|
|
6435
|
+
let textSplit = rt.transformDocuments(this.chunks);
|
|
6436
|
+
if (options?.maxSize) {
|
|
6437
|
+
const textSplitter = new RecursiveCharacterTransformer({
|
|
6438
|
+
maxSize: options.maxSize,
|
|
6439
|
+
overlap: options.overlap,
|
|
6440
|
+
keepSeparator: options.keepSeparator,
|
|
6441
|
+
addStartIndex: options.addStartIndex,
|
|
6442
|
+
stripWhitespace: options.stripWhitespace
|
|
6443
|
+
});
|
|
6444
|
+
textSplit = textSplitter.splitDocuments(textSplit);
|
|
6445
|
+
}
|
|
6397
6446
|
this.chunks = textSplit;
|
|
6398
6447
|
return;
|
|
6399
6448
|
}
|
|
@@ -6803,7 +6852,7 @@ var GraphRAG = class {
|
|
|
6803
6852
|
return neighbors[neighbors.length - 1]?.id;
|
|
6804
6853
|
}
|
|
6805
6854
|
// Perform random walk with restart
|
|
6806
|
-
randomWalkWithRestart(startNodeId, steps, restartProb) {
|
|
6855
|
+
randomWalkWithRestart(startNodeId, steps, restartProb, allowedNodeIds) {
|
|
6807
6856
|
const visits = /* @__PURE__ */ new Map();
|
|
6808
6857
|
let currentNodeId = startNodeId;
|
|
6809
6858
|
for (let step = 0; step < steps; step++) {
|
|
@@ -6812,7 +6861,10 @@ var GraphRAG = class {
|
|
|
6812
6861
|
currentNodeId = startNodeId;
|
|
6813
6862
|
continue;
|
|
6814
6863
|
}
|
|
6815
|
-
|
|
6864
|
+
let neighbors = this.getNeighbors(currentNodeId);
|
|
6865
|
+
if (allowedNodeIds) {
|
|
6866
|
+
neighbors = neighbors.filter((n) => allowedNodeIds.has(n.id));
|
|
6867
|
+
}
|
|
6816
6868
|
if (neighbors.length === 0) {
|
|
6817
6869
|
currentNodeId = startNodeId;
|
|
6818
6870
|
continue;
|
|
@@ -6826,12 +6878,22 @@ var GraphRAG = class {
|
|
|
6826
6878
|
}
|
|
6827
6879
|
return normalizedVisits;
|
|
6828
6880
|
}
|
|
6881
|
+
/**
|
|
6882
|
+
* Query the graph with a dense embedding and optional metadata filter.
|
|
6883
|
+
*
|
|
6884
|
+
* @param query - The embedding vector to query.
|
|
6885
|
+
* @param topK - Number of top results to return.
|
|
6886
|
+
* @param randomWalkSteps - Steps for random walk reranking.
|
|
6887
|
+
* @param restartProb - Restart probability for random walk.
|
|
6888
|
+
* @param filter - Optional strict metadata filter. All key-value pairs must match exactly.
|
|
6889
|
+
*/
|
|
6829
6890
|
// Retrieve relevant nodes using hybrid approach
|
|
6830
6891
|
query({
|
|
6831
6892
|
query,
|
|
6832
6893
|
topK = 10,
|
|
6833
6894
|
randomWalkSteps = 100,
|
|
6834
|
-
restartProb = 0.15
|
|
6895
|
+
restartProb = 0.15,
|
|
6896
|
+
filter
|
|
6835
6897
|
}) {
|
|
6836
6898
|
if (!query || query.length !== this.dimension) {
|
|
6837
6899
|
throw new Error(`Query embedding must have dimension ${this.dimension}`);
|
|
@@ -6845,15 +6907,20 @@ var GraphRAG = class {
|
|
|
6845
6907
|
if (restartProb <= 0 || restartProb >= 1) {
|
|
6846
6908
|
throw new Error("Restart probability must be between 0 and 1");
|
|
6847
6909
|
}
|
|
6848
|
-
const
|
|
6910
|
+
const filterEntries = Object.entries(filter ?? {});
|
|
6911
|
+
const matchesFilter = (node) => filterEntries.length === 0 ? true : filterEntries.every(([key, value]) => node.metadata?.[key] === value);
|
|
6912
|
+
const nodesToSearch = Array.from(this.nodes.values()).filter(matchesFilter);
|
|
6913
|
+
const similarities = nodesToSearch.map((node) => ({
|
|
6849
6914
|
node,
|
|
6850
6915
|
similarity: this.cosineSimilarity(query, node.embedding)
|
|
6851
6916
|
}));
|
|
6852
6917
|
similarities.sort((a, b) => b.similarity - a.similarity);
|
|
6853
6918
|
const topNodes = similarities.slice(0, topK);
|
|
6919
|
+
const useFilter = filterEntries.length > 0;
|
|
6920
|
+
const allowedNodeIds = useFilter ? new Set(nodesToSearch.map((n) => n.id)) : void 0;
|
|
6854
6921
|
const rerankedNodes = /* @__PURE__ */ new Map();
|
|
6855
6922
|
for (const { node, similarity } of topNodes) {
|
|
6856
|
-
const walkScores = this.randomWalkWithRestart(node.id, randomWalkSteps, restartProb);
|
|
6923
|
+
const walkScores = this.randomWalkWithRestart(node.id, randomWalkSteps, restartProb, allowedNodeIds);
|
|
6857
6924
|
for (const [nodeId, walkScore] of walkScores) {
|
|
6858
6925
|
const node2 = this.nodes.get(nodeId);
|
|
6859
6926
|
const existingScore = rerankedNodes.get(nodeId)?.score || 0;
|
|
@@ -7136,9 +7203,9 @@ var createGraphRAGTool = (options) => {
|
|
|
7136
7203
|
return typeof filter === "string" ? JSON.parse(filter) : filter;
|
|
7137
7204
|
} catch (error) {
|
|
7138
7205
|
if (logger) {
|
|
7139
|
-
logger.
|
|
7206
|
+
logger.error("Invalid filter", { filter, error });
|
|
7140
7207
|
}
|
|
7141
|
-
|
|
7208
|
+
throw new Error(`Invalid filter format: ${error instanceof Error ? error.message : String(error)}`);
|
|
7142
7209
|
}
|
|
7143
7210
|
})();
|
|
7144
7211
|
}
|
|
@@ -7263,9 +7330,9 @@ var createVectorQueryTool = (options) => {
|
|
|
7263
7330
|
return typeof filter === "string" ? JSON.parse(filter) : filter;
|
|
7264
7331
|
} catch (error) {
|
|
7265
7332
|
if (logger) {
|
|
7266
|
-
logger.
|
|
7333
|
+
logger.error("Invalid filter", { filter, error });
|
|
7267
7334
|
}
|
|
7268
|
-
|
|
7335
|
+
throw new Error(`Invalid filter format: ${error instanceof Error ? error.message : String(error)}`);
|
|
7269
7336
|
}
|
|
7270
7337
|
})();
|
|
7271
7338
|
}
|