@mastra/pg 1.7.1 → 1.7.2-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 +9 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +17 -1
- package/dist/docs/references/reference-memory-memory-class.md +12 -14
- package/dist/docs/references/reference-processors-message-history-processor.md +7 -9
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +14 -16
- package/dist/docs/references/reference-processors-working-memory-processor.md +14 -18
- package/dist/docs/references/reference-storage-composite.md +9 -9
- package/dist/docs/references/reference-storage-dynamodb.md +9 -9
- package/dist/docs/references/reference-storage-postgresql.md +25 -25
- package/dist/docs/references/reference-tools-vector-query-tool.md +34 -22
- package/dist/docs/references/reference-vectors-pg.md +60 -44
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -4,27 +4,27 @@ The PgVector class provides vector search using [PostgreSQL](https://www.postgre
|
|
|
4
4
|
|
|
5
5
|
## Constructor Options
|
|
6
6
|
|
|
7
|
-
**connectionString
|
|
7
|
+
**connectionString** (`string`): PostgreSQL connection URL
|
|
8
8
|
|
|
9
|
-
**host
|
|
9
|
+
**host** (`string`): PostgreSQL server host
|
|
10
10
|
|
|
11
|
-
**port
|
|
11
|
+
**port** (`number`): PostgreSQL server port
|
|
12
12
|
|
|
13
|
-
**database
|
|
13
|
+
**database** (`string`): PostgreSQL database name
|
|
14
14
|
|
|
15
|
-
**user
|
|
15
|
+
**user** (`string`): PostgreSQL user
|
|
16
16
|
|
|
17
|
-
**password
|
|
17
|
+
**password** (`string`): PostgreSQL password
|
|
18
18
|
|
|
19
|
-
**ssl
|
|
19
|
+
**ssl** (`boolean | ConnectionOptions`): Enable SSL or provide custom SSL configuration
|
|
20
20
|
|
|
21
|
-
**schemaName
|
|
21
|
+
**schemaName** (`string`): The name of the schema you want the vector store to use. Will use the default schema if not provided.
|
|
22
22
|
|
|
23
|
-
**max
|
|
23
|
+
**max** (`number`): Maximum number of pool connections (default: 20)
|
|
24
24
|
|
|
25
|
-
**idleTimeoutMillis
|
|
25
|
+
**idleTimeoutMillis** (`number`): Idle connection timeout in milliseconds (default: 30000)
|
|
26
26
|
|
|
27
|
-
**pgPoolOptions
|
|
27
|
+
**pgPoolOptions** (`PoolConfig`): Additional pg pool configuration options
|
|
28
28
|
|
|
29
29
|
## Constructor Examples
|
|
30
30
|
|
|
@@ -72,23 +72,35 @@ const vectorStore = new PgVector({
|
|
|
72
72
|
|
|
73
73
|
### createIndex()
|
|
74
74
|
|
|
75
|
-
**indexName
|
|
75
|
+
**indexName** (`string`): Name of the index to create
|
|
76
76
|
|
|
77
|
-
**dimension
|
|
77
|
+
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
78
78
|
|
|
79
|
-
**metric
|
|
79
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
80
80
|
|
|
81
|
-
**indexConfig
|
|
81
|
+
**indexConfig** (`IndexConfig`): Index configuration (Default: `{ type: 'ivfflat' }`)
|
|
82
82
|
|
|
83
|
-
**buildIndex
|
|
83
|
+
**buildIndex** (`boolean`): Whether to build the index (Default: `true`)
|
|
84
84
|
|
|
85
85
|
#### IndexConfig
|
|
86
86
|
|
|
87
|
-
**type
|
|
87
|
+
**type** (`'flat' | 'hnsw' | 'ivfflat'`): Index type (Default: `ivfflat`)
|
|
88
88
|
|
|
89
|
-
**
|
|
89
|
+
**type.flat** (`flat`): Sequential scan (no index) that performs exhaustive search.
|
|
90
90
|
|
|
91
|
-
**
|
|
91
|
+
**type.ivfflat** (`ivfflat`): Clusters vectors into lists for approximate search.
|
|
92
|
+
|
|
93
|
+
**type.hnsw** (`hnsw`): Graph-based index offering fast search times and high recall.
|
|
94
|
+
|
|
95
|
+
**ivf** (`IVFConfig`): IVF configuration
|
|
96
|
+
|
|
97
|
+
**ivf.lists** (`number`): Number of lists. If not specified, automatically calculated based on dataset size. (Minimum 100, Maximum 4000)
|
|
98
|
+
|
|
99
|
+
**hnsw** (`HNSWConfig`): HNSW configuration
|
|
100
|
+
|
|
101
|
+
**hnsw\.m** (`number`): Maximum number of connections per node (default: 8)
|
|
102
|
+
|
|
103
|
+
**hnsw\.efConstruction** (`number`): Build-time complexity (default: 32)
|
|
92
104
|
|
|
93
105
|
#### Memory Requirements
|
|
94
106
|
|
|
@@ -102,29 +114,33 @@ Higher M values or efConstruction values will increase memory requirements signi
|
|
|
102
114
|
|
|
103
115
|
### upsert()
|
|
104
116
|
|
|
105
|
-
**indexName
|
|
117
|
+
**indexName** (`string`): Name of the index to upsert vectors into
|
|
106
118
|
|
|
107
|
-
**vectors
|
|
119
|
+
**vectors** (`number[][]`): Array of embedding vectors
|
|
108
120
|
|
|
109
|
-
**metadata
|
|
121
|
+
**metadata** (`Record<string, any>[]`): Metadata for each vector
|
|
110
122
|
|
|
111
|
-
**ids
|
|
123
|
+
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
112
124
|
|
|
113
125
|
### query()
|
|
114
126
|
|
|
115
|
-
**indexName
|
|
127
|
+
**indexName** (`string`): Name of the index to query
|
|
128
|
+
|
|
129
|
+
**queryVector** (`number[]`): Query vector
|
|
130
|
+
|
|
131
|
+
**topK** (`number`): Number of results to return (Default: `10`)
|
|
116
132
|
|
|
117
|
-
**
|
|
133
|
+
**filter** (`Record<string, any>`): Metadata filters
|
|
118
134
|
|
|
119
|
-
**
|
|
135
|
+
**includeVector** (`boolean`): Whether to include the vector in the result (Default: `false`)
|
|
120
136
|
|
|
121
|
-
**
|
|
137
|
+
**minScore** (`number`): Minimum similarity score threshold (Default: `0`)
|
|
122
138
|
|
|
123
|
-
**
|
|
139
|
+
**options** (`{ ef?: number; probes?: number }`): Additional options for HNSW and IVF indexes
|
|
124
140
|
|
|
125
|
-
**
|
|
141
|
+
**options.ef** (`number`): HNSW search parameter
|
|
126
142
|
|
|
127
|
-
**options
|
|
143
|
+
**options.probes** (`number`): IVF search parameter
|
|
128
144
|
|
|
129
145
|
### listIndexes()
|
|
130
146
|
|
|
@@ -132,7 +148,7 @@ Returns an array of index names as strings.
|
|
|
132
148
|
|
|
133
149
|
### describeIndex()
|
|
134
150
|
|
|
135
|
-
**indexName
|
|
151
|
+
**indexName** (`string`): Name of the index to describe
|
|
136
152
|
|
|
137
153
|
Returns:
|
|
138
154
|
|
|
@@ -153,19 +169,19 @@ interface PGIndexStats {
|
|
|
153
169
|
|
|
154
170
|
### deleteIndex()
|
|
155
171
|
|
|
156
|
-
**indexName
|
|
172
|
+
**indexName** (`string`): Name of the index to delete
|
|
157
173
|
|
|
158
174
|
### updateVector()
|
|
159
175
|
|
|
160
176
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
161
177
|
|
|
162
|
-
**indexName
|
|
178
|
+
**indexName** (`string`): Name of the index containing the vector
|
|
163
179
|
|
|
164
|
-
**id
|
|
180
|
+
**id** (`string`): ID of the vector to update (mutually exclusive with filter)
|
|
165
181
|
|
|
166
|
-
**filter
|
|
182
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vector(s) to update (mutually exclusive with id)
|
|
167
183
|
|
|
168
|
-
**update
|
|
184
|
+
**update** (`{ vector?: number[]; metadata?: Record<string, any>; }`): Object containing the vector and/or metadata to update
|
|
169
185
|
|
|
170
186
|
Updates an existing vector by ID or filter. At least one of vector or metadata must be provided in the update object.
|
|
171
187
|
|
|
@@ -192,9 +208,9 @@ await pgVector.updateVector({
|
|
|
192
208
|
|
|
193
209
|
### deleteVector()
|
|
194
210
|
|
|
195
|
-
**indexName
|
|
211
|
+
**indexName** (`string`): Name of the index containing the vector
|
|
196
212
|
|
|
197
|
-
**id
|
|
213
|
+
**id** (`string`): ID of the vector to delete
|
|
198
214
|
|
|
199
215
|
Deletes a single vector by ID from the specified index.
|
|
200
216
|
|
|
@@ -206,11 +222,11 @@ await pgVector.deleteVector({ indexName: 'my_vectors', id: 'vector123' })
|
|
|
206
222
|
|
|
207
223
|
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
208
224
|
|
|
209
|
-
**indexName
|
|
225
|
+
**indexName** (`string`): Name of the index containing the vectors to delete
|
|
210
226
|
|
|
211
|
-
**ids
|
|
227
|
+
**ids** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
|
|
212
228
|
|
|
213
|
-
**filter
|
|
229
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
|
|
214
230
|
|
|
215
231
|
### disconnect()
|
|
216
232
|
|
|
@@ -218,11 +234,11 @@ Closes the database connection pool. Should be called when done using the store.
|
|
|
218
234
|
|
|
219
235
|
### buildIndex()
|
|
220
236
|
|
|
221
|
-
**indexName
|
|
237
|
+
**indexName** (`string`): Name of the index to define
|
|
222
238
|
|
|
223
|
-
**metric
|
|
239
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
224
240
|
|
|
225
|
-
**indexConfig
|
|
241
|
+
**indexConfig** (`IndexConfig`): Configuration for the index type and parameters
|
|
226
242
|
|
|
227
243
|
Builds or rebuilds an index with specified metric and configuration. Will drop any existing index before creating the new one.
|
|
228
244
|
|
package/dist/index.cjs
CHANGED
|
@@ -5187,6 +5187,10 @@ var ExperimentsPG = class _ExperimentsPG extends storage.ExperimentsStorage {
|
|
|
5187
5187
|
setClauses.push(`"failedCount" = $${paramIndex++}`);
|
|
5188
5188
|
values.push(input.failedCount);
|
|
5189
5189
|
}
|
|
5190
|
+
if (input.totalItems !== void 0) {
|
|
5191
|
+
setClauses.push(`"totalItems" = $${paramIndex++}`);
|
|
5192
|
+
values.push(input.totalItems);
|
|
5193
|
+
}
|
|
5190
5194
|
if (input.skippedCount !== void 0) {
|
|
5191
5195
|
setClauses.push(`"skippedCount" = $${paramIndex++}`);
|
|
5192
5196
|
values.push(input.skippedCount);
|