@mastra/pg 1.2.0 → 1.3.0-alpha.0
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 +91 -0
- package/dist/docs/SKILL.md +28 -25
- package/dist/docs/{SOURCE_MAP.json → assets/SOURCE_MAP.json} +1 -1
- package/dist/docs/{memory/03-semantic-recall.md → references/docs-memory-semantic-recall.md} +33 -17
- package/dist/docs/{memory/01-storage.md → references/docs-memory-storage.md} +29 -39
- package/dist/docs/{memory/02-working-memory.md → references/docs-memory-working-memory.md} +16 -27
- package/dist/docs/{rag/01-overview.md → references/docs-rag-overview.md} +2 -4
- package/dist/docs/{rag/03-retrieval.md → references/docs-rag-retrieval.md} +26 -53
- package/dist/docs/{rag/02-vector-databases.md → references/docs-rag-vector-databases.md} +198 -202
- package/dist/docs/{memory/04-reference.md → references/reference-memory-memory-class.md} +28 -14
- package/dist/docs/references/reference-processors-message-history-processor.md +85 -0
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +123 -0
- package/dist/docs/references/reference-processors-working-memory-processor.md +154 -0
- package/dist/docs/{rag/04-reference.md → references/reference-rag-metadata-filters.md} +26 -179
- package/dist/docs/references/reference-storage-composite.md +235 -0
- package/dist/docs/references/reference-storage-dynamodb.md +282 -0
- package/dist/docs/references/reference-storage-postgresql.md +529 -0
- package/dist/docs/{tools/01-reference.md → references/reference-tools-vector-query-tool.md} +137 -118
- package/dist/docs/{vectors/01-reference.md → references/reference-vectors-pg.md} +115 -14
- package/dist/index.cjs +1998 -217
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1998 -219
- package/dist/index.js.map +1 -1
- package/dist/storage/db/constraint-utils.d.ts +16 -0
- package/dist/storage/db/constraint-utils.d.ts.map +1 -0
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/agents/index.d.ts +9 -12
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +7 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/index.d.ts +33 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts +33 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +3 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +2 -3
- package/dist/docs/README.md +0 -36
- package/dist/docs/processors/01-reference.md +0 -296
- package/dist/docs/storage/01-reference.md +0 -905
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
> Guide on retrieval processes in Mastra
|
|
2
|
-
|
|
3
1
|
# Retrieval in RAG Systems
|
|
4
2
|
|
|
5
3
|
After storing embeddings, you need to retrieve relevant chunks to answer user queries.
|
|
@@ -168,10 +166,9 @@ This is particularly useful when:
|
|
|
168
166
|
|
|
169
167
|
The Vector Query Tool supports database-specific configurations that enable you to leverage unique features and optimizations of different vector stores.
|
|
170
168
|
|
|
171
|
-
> **Note:**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
Connection credentials (URLs, auth tokens) are configured when you instantiate the vector store class (e.g., `new LibSQLVector({ url: '...' })`).
|
|
169
|
+
> **Note:** These configurations are for **query-time options** like namespaces, performance tuning, and filtering—not for database connection setup.
|
|
170
|
+
>
|
|
171
|
+
> Connection credentials (URLs, auth tokens) are configured when you instantiate the vector store class (e.g., `new LibSQLVector({ url: '...' })`).
|
|
175
172
|
|
|
176
173
|
```ts
|
|
177
174
|
import { createVectorQueryTool } from "@mastra/rag";
|
|
@@ -268,10 +265,9 @@ For detailed configuration options and advanced usage, see the [Vector Query Too
|
|
|
268
265
|
|
|
269
266
|
### Vector Store Prompts
|
|
270
267
|
|
|
271
|
-
Vector store prompts define query patterns and filtering capabilities for each vector database implementation.
|
|
272
|
-
When implementing filtering, these prompts are required in the agent's instructions to specify valid operators and syntax for each vector store implementation.
|
|
268
|
+
Vector store prompts define query patterns and filtering capabilities for each vector database implementation. When implementing filtering, these prompts are required in the agent's instructions to specify valid operators and syntax for each vector store implementation.
|
|
273
269
|
|
|
274
|
-
|
|
270
|
+
**pgVector**:
|
|
275
271
|
|
|
276
272
|
```ts
|
|
277
273
|
import { PGVECTOR_PROMPT } from "@mastra/pg";
|
|
@@ -288,11 +284,9 @@ export const ragAgent = new Agent({
|
|
|
288
284
|
});
|
|
289
285
|
```
|
|
290
286
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
**pinecone:**
|
|
287
|
+
**Pinecone**:
|
|
294
288
|
|
|
295
|
-
```ts
|
|
289
|
+
```ts
|
|
296
290
|
import { PINECONE_PROMPT } from "@mastra/pinecone";
|
|
297
291
|
|
|
298
292
|
export const ragAgent = new Agent({
|
|
@@ -307,11 +301,9 @@ export const ragAgent = new Agent({
|
|
|
307
301
|
});
|
|
308
302
|
```
|
|
309
303
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
**qdrant:**
|
|
304
|
+
**Qdrant**:
|
|
313
305
|
|
|
314
|
-
```ts
|
|
306
|
+
```ts
|
|
315
307
|
import { QDRANT_PROMPT } from "@mastra/qdrant";
|
|
316
308
|
|
|
317
309
|
export const ragAgent = new Agent({
|
|
@@ -326,11 +318,9 @@ export const ragAgent = new Agent({
|
|
|
326
318
|
});
|
|
327
319
|
```
|
|
328
320
|
|
|
329
|
-
|
|
321
|
+
**Chroma**:
|
|
330
322
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
```ts title="vector-store.ts"
|
|
323
|
+
```ts
|
|
334
324
|
import { CHROMA_PROMPT } from "@mastra/chroma";
|
|
335
325
|
|
|
336
326
|
export const ragAgent = new Agent({
|
|
@@ -345,11 +335,9 @@ export const ragAgent = new Agent({
|
|
|
345
335
|
});
|
|
346
336
|
```
|
|
347
337
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
**astra:**
|
|
338
|
+
**Astra**:
|
|
351
339
|
|
|
352
|
-
```ts
|
|
340
|
+
```ts
|
|
353
341
|
import { ASTRA_PROMPT } from "@mastra/astra";
|
|
354
342
|
|
|
355
343
|
export const ragAgent = new Agent({
|
|
@@ -364,11 +352,9 @@ export const ragAgent = new Agent({
|
|
|
364
352
|
});
|
|
365
353
|
```
|
|
366
354
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
**libsql:**
|
|
355
|
+
**libSQL**:
|
|
370
356
|
|
|
371
|
-
```ts
|
|
357
|
+
```ts
|
|
372
358
|
import { LIBSQL_PROMPT } from "@mastra/libsql";
|
|
373
359
|
|
|
374
360
|
export const ragAgent = new Agent({
|
|
@@ -383,11 +369,9 @@ export const ragAgent = new Agent({
|
|
|
383
369
|
});
|
|
384
370
|
```
|
|
385
371
|
|
|
386
|
-
|
|
372
|
+
**Upstash**:
|
|
387
373
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
```ts title="vector-store.ts"
|
|
374
|
+
```ts
|
|
391
375
|
import { UPSTASH_PROMPT } from "@mastra/upstash";
|
|
392
376
|
|
|
393
377
|
export const ragAgent = new Agent({
|
|
@@ -402,11 +386,9 @@ export const ragAgent = new Agent({
|
|
|
402
386
|
});
|
|
403
387
|
```
|
|
404
388
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
**vectorize:**
|
|
389
|
+
**Vectorize**:
|
|
408
390
|
|
|
409
|
-
```ts
|
|
391
|
+
```ts
|
|
410
392
|
import { VECTORIZE_PROMPT } from "@mastra/vectorize";
|
|
411
393
|
|
|
412
394
|
export const ragAgent = new Agent({
|
|
@@ -421,11 +403,9 @@ export const ragAgent = new Agent({
|
|
|
421
403
|
});
|
|
422
404
|
```
|
|
423
405
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
**mongodb:**
|
|
406
|
+
**MongoDB**:
|
|
427
407
|
|
|
428
|
-
```ts
|
|
408
|
+
```ts
|
|
429
409
|
import { MONGODB_PROMPT } from "@mastra/mongodb";
|
|
430
410
|
|
|
431
411
|
export const ragAgent = new Agent({
|
|
@@ -440,11 +420,9 @@ export const ragAgent = new Agent({
|
|
|
440
420
|
});
|
|
441
421
|
```
|
|
442
422
|
|
|
443
|
-
|
|
423
|
+
**OpenSearch**:
|
|
444
424
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
```ts title="vector-store.ts"
|
|
425
|
+
```ts
|
|
448
426
|
import { OPENSEARCH_PROMPT } from "@mastra/opensearch";
|
|
449
427
|
|
|
450
428
|
export const ragAgent = new Agent({
|
|
@@ -459,11 +437,9 @@ export const ragAgent = new Agent({
|
|
|
459
437
|
});
|
|
460
438
|
```
|
|
461
439
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
**s3vectors:**
|
|
440
|
+
**S3Vectors**:
|
|
465
441
|
|
|
466
|
-
```ts
|
|
442
|
+
```ts
|
|
467
443
|
import { S3VECTORS_PROMPT } from "@mastra/s3vectors";
|
|
468
444
|
|
|
469
445
|
export const ragAgent = new Agent({
|
|
@@ -478,8 +454,6 @@ export const ragAgent = new Agent({
|
|
|
478
454
|
});
|
|
479
455
|
```
|
|
480
456
|
|
|
481
|
-
|
|
482
|
-
|
|
483
457
|
### Re-ranking
|
|
484
458
|
|
|
485
459
|
Initial vector similarity search can sometimes miss nuanced relevance. Re-ranking is a more computationally expensive process, but more accurate algorithm that improves results by:
|
|
@@ -528,8 +502,7 @@ The weights control how different factors influence the final ranking:
|
|
|
528
502
|
- `vector`: Higher values favor the original vector similarity scores
|
|
529
503
|
- `position`: Higher values help maintain the original ordering of results
|
|
530
504
|
|
|
531
|
-
> **Note:**
|
|
532
|
-
For semantic scoring to work properly during re-ranking, each result must include the text content in its `metadata.text` field.
|
|
505
|
+
> **Note:** For semantic scoring to work properly during re-ranking, each result must include the text content in its `metadata.text` field.
|
|
533
506
|
|
|
534
507
|
You can also use other relevance score providers like Cohere or ZeroEntropy:
|
|
535
508
|
|