@mastra/rag 1.2.3-alpha.0 → 1.2.3-alpha.2

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +19 -6
  3. package/.turbo/turbo-build.log +0 -4
  4. package/docker-compose.yaml +0 -22
  5. package/eslint.config.js +0 -6
  6. package/src/document/document.test.ts +0 -2975
  7. package/src/document/document.ts +0 -335
  8. package/src/document/extractors/base.ts +0 -30
  9. package/src/document/extractors/index.ts +0 -5
  10. package/src/document/extractors/keywords.test.ts +0 -125
  11. package/src/document/extractors/keywords.ts +0 -126
  12. package/src/document/extractors/questions.test.ts +0 -120
  13. package/src/document/extractors/questions.ts +0 -111
  14. package/src/document/extractors/summary.test.ts +0 -107
  15. package/src/document/extractors/summary.ts +0 -122
  16. package/src/document/extractors/title.test.ts +0 -121
  17. package/src/document/extractors/title.ts +0 -185
  18. package/src/document/extractors/types.ts +0 -40
  19. package/src/document/index.ts +0 -2
  20. package/src/document/prompts/base.ts +0 -77
  21. package/src/document/prompts/format.ts +0 -9
  22. package/src/document/prompts/index.ts +0 -15
  23. package/src/document/prompts/prompt.ts +0 -60
  24. package/src/document/prompts/types.ts +0 -29
  25. package/src/document/schema/index.ts +0 -3
  26. package/src/document/schema/node.ts +0 -187
  27. package/src/document/schema/types.ts +0 -40
  28. package/src/document/transformers/character.ts +0 -267
  29. package/src/document/transformers/html.ts +0 -346
  30. package/src/document/transformers/json.ts +0 -536
  31. package/src/document/transformers/latex.ts +0 -11
  32. package/src/document/transformers/markdown.ts +0 -239
  33. package/src/document/transformers/semantic-markdown.ts +0 -227
  34. package/src/document/transformers/sentence.ts +0 -314
  35. package/src/document/transformers/text.ts +0 -158
  36. package/src/document/transformers/token.ts +0 -137
  37. package/src/document/transformers/transformer.ts +0 -5
  38. package/src/document/types.ts +0 -145
  39. package/src/document/validation.ts +0 -158
  40. package/src/graph-rag/index.test.ts +0 -235
  41. package/src/graph-rag/index.ts +0 -306
  42. package/src/index.ts +0 -8
  43. package/src/rerank/index.test.ts +0 -150
  44. package/src/rerank/index.ts +0 -198
  45. package/src/rerank/relevance/cohere/index.ts +0 -56
  46. package/src/rerank/relevance/index.ts +0 -3
  47. package/src/rerank/relevance/mastra-agent/index.ts +0 -32
  48. package/src/rerank/relevance/zeroentropy/index.ts +0 -26
  49. package/src/tools/README.md +0 -153
  50. package/src/tools/document-chunker.ts +0 -34
  51. package/src/tools/graph-rag.test.ts +0 -115
  52. package/src/tools/graph-rag.ts +0 -157
  53. package/src/tools/index.ts +0 -3
  54. package/src/tools/types.ts +0 -126
  55. package/src/tools/vector-query-database-config.test.ts +0 -190
  56. package/src/tools/vector-query.test.ts +0 -477
  57. package/src/tools/vector-query.ts +0 -171
  58. package/src/utils/convert-sources.ts +0 -43
  59. package/src/utils/default-settings.ts +0 -38
  60. package/src/utils/index.ts +0 -3
  61. package/src/utils/tool-schemas.ts +0 -38
  62. package/src/utils/vector-prompts.ts +0 -832
  63. package/src/utils/vector-search.ts +0 -130
  64. package/tsconfig.build.json +0 -9
  65. package/tsconfig.json +0 -5
  66. package/tsup.config.ts +0 -17
  67. package/vitest.config.ts +0 -8
@@ -1,38 +0,0 @@
1
- export const defaultVectorQueryDescription = () =>
2
- `Access the knowledge base to find information needed to answer user questions.`;
3
-
4
- export const defaultGraphRagDescription = () =>
5
- `Access and analyze relationships between information in the knowledge base to answer complex questions about connections and patterns.`;
6
-
7
- export const queryTextDescription = `The text query to search for in the vector database.
8
- - ALWAYS provide a non-empty query string
9
- - Must contain the user's question or search terms
10
- - Example: "market data" or "financial reports"
11
- - If the user's query is about a specific topic, use that topic as the queryText
12
- - Cannot be an empty string
13
- - Do not include quotes, just the text itself
14
- - Required for all searches`;
15
-
16
- export const topKDescription = `Controls how many matching documents to return.
17
- - ALWAYS provide a value
18
- - If no value is provided, use the default (10)
19
- - Must be a valid and positive number
20
- - Cannot be NaN
21
- - Uses provided value if specified
22
- - Default: 10 results (use this if unsure)
23
- - Higher values (like 20) provide more context
24
- - Lower values (like 3) focus on best matches
25
- - Based on query requirements`;
26
-
27
- export const filterDescription = `JSON-formatted criteria to refine search results.
28
- - ALWAYS provide a filter value
29
- - If no filter is provided, use the default ("{}")
30
- - MUST be a valid, complete JSON object with proper quotes and brackets
31
- - Uses provided filter if specified
32
- - Default: "{}" (no filtering)
33
- - Example for no filtering: "filter": "{}"
34
- - Example: '{"category": "health"}'
35
- - Based on query intent
36
- - Do NOT use single quotes or unquoted properties
37
- - IMPORTANT: Always ensure JSON is properly closed with matching brackets
38
- - Multiple filters can be combined`;
@@ -1,3 +0,0 @@
1
- export * from './vector-search';
2
- export * from './default-settings';
3
- export * from './tool-schemas';
@@ -1,38 +0,0 @@
1
- import type { Tool } from '@mastra/core/tools';
2
- import { z } from 'zod';
3
- import { queryTextDescription, topKDescription, filterDescription } from './default-settings';
4
-
5
- export const baseSchema = {
6
- queryText: z.string().describe(queryTextDescription),
7
- topK: z.coerce.number().describe(topKDescription),
8
- };
9
-
10
- // Output schema includes `sources`, which exposes the full set of retrieved chunks (QueryResult objects)
11
- // Each source contains all information needed to reference
12
- // the original document, chunk, and similarity score.
13
- export const outputSchema = z.object({
14
- // Array of metadata or content for compatibility with prior usage
15
- relevantContext: z.any(),
16
- // Array of full retrieval result objects
17
- sources: z.array(
18
- z.object({
19
- id: z.string(), // Unique chunk/document identifier
20
- metadata: z.any(), // All metadata fields (document ID, etc.)
21
- vector: z.array(z.number()), // Embedding vector (if available)
22
- score: z.number(), // Similarity score for this retrieval
23
- document: z.string(), // Full chunk/document text (if available)
24
- }),
25
- ),
26
- });
27
-
28
- export const filterSchema = z.object({
29
- ...baseSchema,
30
- filter: z.coerce.string().describe(filterDescription),
31
- });
32
-
33
- export type RagTool<
34
- TInput extends z.ZodType<any, z.ZodTypeDef, any> | undefined,
35
- TOutput extends z.ZodType<any, z.ZodTypeDef, any> | undefined,
36
- > = Tool<TInput, TOutput> & {
37
- execute: NonNullable<Tool<TInput, TOutput>['execute']>;
38
- };