@mastra/memory 1.6.1 → 1.6.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.
- package/CHANGELOG.md +52 -0
- package/dist/{chunk-GBBQIJQF.js → chunk-3CM4XQJO.js} +1940 -463
- package/dist/chunk-3CM4XQJO.js.map +1 -0
- package/dist/{chunk-D6II7EP4.cjs → chunk-5W5463NI.cjs} +1939 -461
- package/dist/chunk-5W5463NI.cjs.map +1 -0
- package/dist/docs/SKILL.md +24 -24
- package/dist/docs/assets/SOURCE_MAP.json +25 -25
- package/dist/docs/references/docs-agents-agent-approval.md +3 -3
- package/dist/docs/references/docs-agents-agent-memory.md +3 -3
- package/dist/docs/references/docs-agents-network-approval.md +5 -2
- package/dist/docs/references/docs-agents-networks.md +2 -2
- package/dist/docs/references/docs-agents-supervisor-agents.md +3 -3
- package/dist/docs/references/docs-memory-memory-processors.md +9 -9
- package/dist/docs/references/docs-memory-message-history.md +4 -4
- package/dist/docs/references/docs-memory-observational-memory.md +11 -7
- package/dist/docs/references/docs-memory-semantic-recall.md +9 -9
- package/dist/docs/references/docs-memory-storage.md +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +20 -20
- package/dist/docs/references/reference-core-getMemory.md +1 -1
- package/dist/docs/references/reference-core-listMemory.md +1 -1
- package/dist/docs/references/reference-memory-clone-utilities.md +7 -7
- package/dist/docs/references/reference-memory-cloneThread.md +5 -5
- package/dist/docs/references/reference-memory-createThread.md +1 -1
- package/dist/docs/references/reference-memory-getThreadById.md +1 -1
- package/dist/docs/references/reference-memory-listThreads.md +3 -3
- package/dist/docs/references/reference-memory-memory-class.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +8 -6
- package/dist/docs/references/reference-processors-token-limiter-processor.md +2 -2
- package/dist/docs/references/reference-storage-dynamodb.md +7 -7
- package/dist/docs/references/reference-storage-libsql.md +1 -1
- package/dist/docs/references/reference-storage-mongodb.md +6 -6
- package/dist/docs/references/reference-storage-postgresql.md +7 -7
- package/dist/docs/references/reference-storage-upstash.md +4 -4
- package/dist/docs/references/reference-vectors-libsql.md +15 -15
- package/dist/docs/references/reference-vectors-mongodb.md +18 -18
- package/dist/docs/references/reference-vectors-pg.md +23 -21
- package/dist/docs/references/reference-vectors-upstash.md +15 -15
- package/dist/index.cjs +48 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -21
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-AHVELJX4.cjs → observational-memory-C5LO7RBR.cjs} +17 -17
- package/dist/{observational-memory-AHVELJX4.cjs.map → observational-memory-C5LO7RBR.cjs.map} +1 -1
- package/dist/{observational-memory-QFQUF5EY.js → observational-memory-OYK4MEUD.js} +3 -3
- package/dist/{observational-memory-QFQUF5EY.js.map → observational-memory-OYK4MEUD.js.map} +1 -1
- package/dist/processors/index.cjs +15 -15
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +33 -2
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts +7 -4
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/repro-capture.d.ts +23 -0
- package/dist/processors/observational-memory/repro-capture.d.ts.map +1 -0
- package/dist/processors/observational-memory/token-counter.d.ts +28 -3
- package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
- package/dist/tools/working-memory.d.ts +6 -10
- package/dist/tools/working-memory.d.ts.map +1 -1
- package/package.json +16 -11
- package/dist/chunk-D6II7EP4.cjs.map +0 -1
- package/dist/chunk-GBBQIJQF.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# libSQL
|
|
1
|
+
# libSQL vector store
|
|
2
2
|
|
|
3
3
|
The libSQL storage implementation provides a SQLite-compatible vector search [libSQL](https://github.com/tursodatabase/libsql), a fork of SQLite with vector extensions, and [Turso](https://turso.tech/) with vector extensions, offering a lightweight and efficient vector database solution. It's part of the `@mastra/libsql` package and offers efficient vector similarity search with metadata filtering.
|
|
4
4
|
|
|
@@ -69,7 +69,7 @@ const results = await store.query({
|
|
|
69
69
|
});
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
## Constructor
|
|
72
|
+
## Constructor options
|
|
73
73
|
|
|
74
74
|
**url** (`string`): libSQL database URL. Use ':memory:' for in-memory database, 'file:dbname.db' for local file, or a libSQL-compatible connection string like 'libsql://your-database.turso.io'.
|
|
75
75
|
|
|
@@ -81,7 +81,7 @@ const results = await store.query({
|
|
|
81
81
|
|
|
82
82
|
## Methods
|
|
83
83
|
|
|
84
|
-
### createIndex()
|
|
84
|
+
### `createIndex()`
|
|
85
85
|
|
|
86
86
|
Creates a new vector collection. The index name must start with a letter or underscore and can only contain letters, numbers, and underscores. The dimension must be a positive integer.
|
|
87
87
|
|
|
@@ -91,7 +91,7 @@ Creates a new vector collection. The index name must start with a letter or unde
|
|
|
91
91
|
|
|
92
92
|
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search. Note: Currently only cosine similarity is supported by libSQL. (Default: `cosine`)
|
|
93
93
|
|
|
94
|
-
### upsert()
|
|
94
|
+
### `upsert()`
|
|
95
95
|
|
|
96
96
|
Adds or updates vectors and their metadata in the index. Uses a transaction to ensure all vectors are inserted atomically - if any insert fails, the entire operation is rolled back.
|
|
97
97
|
|
|
@@ -103,7 +103,7 @@ Adds or updates vectors and their metadata in the index. Uses a transaction to e
|
|
|
103
103
|
|
|
104
104
|
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
105
105
|
|
|
106
|
-
### query()
|
|
106
|
+
### `query()`
|
|
107
107
|
|
|
108
108
|
Searches for similar vectors with optional metadata filtering.
|
|
109
109
|
|
|
@@ -119,7 +119,7 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
119
119
|
|
|
120
120
|
**minScore** (`number`): Minimum similarity score threshold (Default: `0`)
|
|
121
121
|
|
|
122
|
-
### describeIndex()
|
|
122
|
+
### `describeIndex()`
|
|
123
123
|
|
|
124
124
|
Gets information about an index.
|
|
125
125
|
|
|
@@ -135,25 +135,25 @@ interface IndexStats {
|
|
|
135
135
|
}
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
### deleteIndex()
|
|
138
|
+
### `deleteIndex()`
|
|
139
139
|
|
|
140
140
|
Deletes an index and all its data.
|
|
141
141
|
|
|
142
142
|
**indexName** (`string`): Name of the index to delete
|
|
143
143
|
|
|
144
|
-
### listIndexes()
|
|
144
|
+
### `listIndexes()`
|
|
145
145
|
|
|
146
146
|
Lists all vector indexes in the database.
|
|
147
147
|
|
|
148
148
|
Returns: `Promise<string[]>`
|
|
149
149
|
|
|
150
|
-
### truncateIndex()
|
|
150
|
+
### `truncateIndex()`
|
|
151
151
|
|
|
152
152
|
Removes all vectors from an index while keeping the index structure.
|
|
153
153
|
|
|
154
154
|
**indexName** (`string`): Name of the index to truncate
|
|
155
155
|
|
|
156
|
-
### updateVector()
|
|
156
|
+
### `updateVector()`
|
|
157
157
|
|
|
158
158
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
159
159
|
|
|
@@ -169,7 +169,7 @@ Update a single vector by ID or by metadata filter. Either `id` or `filter` must
|
|
|
169
169
|
|
|
170
170
|
**update.metadata** (`Record<string, any>`): New metadata to update
|
|
171
171
|
|
|
172
|
-
### deleteVector()
|
|
172
|
+
### `deleteVector()`
|
|
173
173
|
|
|
174
174
|
Deletes a specific vector entry from an index by its ID.
|
|
175
175
|
|
|
@@ -177,7 +177,7 @@ Deletes a specific vector entry from an index by its ID.
|
|
|
177
177
|
|
|
178
178
|
**id** (`string`): ID of the vector entry to delete
|
|
179
179
|
|
|
180
|
-
### deleteVectors()
|
|
180
|
+
### `deleteVectors()`
|
|
181
181
|
|
|
182
182
|
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
183
183
|
|
|
@@ -187,7 +187,7 @@ Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` m
|
|
|
187
187
|
|
|
188
188
|
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
|
|
189
189
|
|
|
190
|
-
## Response
|
|
190
|
+
## Response types
|
|
191
191
|
|
|
192
192
|
Query results are returned in this format:
|
|
193
193
|
|
|
@@ -200,7 +200,7 @@ interface QueryResult {
|
|
|
200
200
|
}
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
-
## Error
|
|
203
|
+
## Error handling
|
|
204
204
|
|
|
205
205
|
The store throws specific errors for different failure cases:
|
|
206
206
|
|
|
@@ -232,7 +232,7 @@ Common error cases include:
|
|
|
232
232
|
- Database connection issues
|
|
233
233
|
- Transaction failures during upsert
|
|
234
234
|
|
|
235
|
-
## Usage
|
|
235
|
+
## Usage example
|
|
236
236
|
|
|
237
237
|
### Local embeddings with fastembed
|
|
238
238
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# MongoDB
|
|
1
|
+
# MongoDB vector store
|
|
2
2
|
|
|
3
3
|
The `MongoDBVector` class provides vector search using [MongoDB Atlas Vector Search](https://www.mongodb.com/docs/atlas/atlas-vector-search/). It enables efficient similarity search and metadata filtering within your MongoDB collections.
|
|
4
4
|
|
|
@@ -28,7 +28,7 @@ yarn add @mastra/mongodb@latest
|
|
|
28
28
|
bun add @mastra/mongodb@latest
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
## Usage
|
|
31
|
+
## Usage example
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
34
|
import { MongoDBVector } from '@mastra/mongodb'
|
|
@@ -55,7 +55,7 @@ const store = new MongoDBVector({
|
|
|
55
55
|
})
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
## Constructor
|
|
58
|
+
## Constructor options
|
|
59
59
|
|
|
60
60
|
**id** (`string`): Unique identifier for this vector store instance
|
|
61
61
|
|
|
@@ -69,7 +69,7 @@ const store = new MongoDBVector({
|
|
|
69
69
|
|
|
70
70
|
## Methods
|
|
71
71
|
|
|
72
|
-
### createIndex()
|
|
72
|
+
### `createIndex()`
|
|
73
73
|
|
|
74
74
|
Creates a new vector index (collection) in MongoDB.
|
|
75
75
|
|
|
@@ -79,7 +79,7 @@ Creates a new vector index (collection) in MongoDB.
|
|
|
79
79
|
|
|
80
80
|
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
81
81
|
|
|
82
|
-
### upsert()
|
|
82
|
+
### `upsert()`
|
|
83
83
|
|
|
84
84
|
Adds or updates vectors and their metadata in the collection.
|
|
85
85
|
|
|
@@ -91,7 +91,7 @@ Adds or updates vectors and their metadata in the collection.
|
|
|
91
91
|
|
|
92
92
|
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
93
93
|
|
|
94
|
-
### query()
|
|
94
|
+
### `query()`
|
|
95
95
|
|
|
96
96
|
Searches for similar vectors with optional metadata filtering.
|
|
97
97
|
|
|
@@ -109,7 +109,7 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
109
109
|
|
|
110
110
|
**minScore** (`number`): Minimum similarity score threshold (Default: `0`)
|
|
111
111
|
|
|
112
|
-
### describeIndex()
|
|
112
|
+
### `describeIndex()`
|
|
113
113
|
|
|
114
114
|
Returns information about the index (collection).
|
|
115
115
|
|
|
@@ -125,19 +125,19 @@ interface IndexStats {
|
|
|
125
125
|
}
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
### deleteIndex()
|
|
128
|
+
### `deleteIndex()`
|
|
129
129
|
|
|
130
130
|
Deletes a collection and all its data.
|
|
131
131
|
|
|
132
132
|
**indexName** (`string`): Name of the collection to delete
|
|
133
133
|
|
|
134
|
-
### listIndexes()
|
|
134
|
+
### `listIndexes()`
|
|
135
135
|
|
|
136
136
|
Lists all vector collections in the MongoDB database.
|
|
137
137
|
|
|
138
138
|
Returns: `Promise<string[]>`
|
|
139
139
|
|
|
140
|
-
### updateVector()
|
|
140
|
+
### `updateVector()`
|
|
141
141
|
|
|
142
142
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
143
143
|
|
|
@@ -153,7 +153,7 @@ Update a single vector by ID or by metadata filter. Either `id` or `filter` must
|
|
|
153
153
|
|
|
154
154
|
**update.metadata** (`Record<string, any>`): New metadata to update
|
|
155
155
|
|
|
156
|
-
### deleteVector()
|
|
156
|
+
### `deleteVector()`
|
|
157
157
|
|
|
158
158
|
Deletes a specific vector entry from an index by its ID.
|
|
159
159
|
|
|
@@ -161,7 +161,7 @@ Deletes a specific vector entry from an index by its ID.
|
|
|
161
161
|
|
|
162
162
|
**id** (`string`): ID of the vector entry to delete
|
|
163
163
|
|
|
164
|
-
### deleteVectors()
|
|
164
|
+
### `deleteVectors()`
|
|
165
165
|
|
|
166
166
|
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
167
167
|
|
|
@@ -171,11 +171,11 @@ Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` m
|
|
|
171
171
|
|
|
172
172
|
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
|
|
173
173
|
|
|
174
|
-
### disconnect()
|
|
174
|
+
### `disconnect()`
|
|
175
175
|
|
|
176
176
|
Closes the MongoDB client connection. Should be called when done using the store.
|
|
177
177
|
|
|
178
|
-
## Response
|
|
178
|
+
## Response types
|
|
179
179
|
|
|
180
180
|
Query results are returned in this format:
|
|
181
181
|
|
|
@@ -188,7 +188,7 @@ interface QueryResult {
|
|
|
188
188
|
}
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
## Error
|
|
191
|
+
## Error handling
|
|
192
192
|
|
|
193
193
|
The store throws typed errors that can be caught:
|
|
194
194
|
|
|
@@ -212,15 +212,15 @@ try {
|
|
|
212
212
|
}
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
-
## Best
|
|
215
|
+
## Best practices
|
|
216
216
|
|
|
217
217
|
- Index metadata fields used in filters for optimal query performance.
|
|
218
218
|
- Use consistent field naming in metadata to avoid unexpected query results.
|
|
219
219
|
- Regularly monitor index and collection statistics to ensure efficient search.
|
|
220
220
|
|
|
221
|
-
## Usage
|
|
221
|
+
## Usage example
|
|
222
222
|
|
|
223
|
-
### Vector embeddings with MongoDB
|
|
223
|
+
### Vector embeddings with `MongoDB`
|
|
224
224
|
|
|
225
225
|
Embeddings are numeric vectors used by memory's `semanticRecall` to retrieve related messages by meaning (not keywords).
|
|
226
226
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# PG
|
|
1
|
+
# PG vector store
|
|
2
2
|
|
|
3
3
|
The PgVector class provides vector search using [PostgreSQL](https://www.postgresql.org/) with [pgvector](https://github.com/pgvector/pgvector) extension. It provides robust vector similarity search capabilities within your existing PostgreSQL database.
|
|
4
4
|
|
|
5
|
-
## Constructor
|
|
5
|
+
## Constructor options
|
|
6
6
|
|
|
7
7
|
**connectionString** (`string`): PostgreSQL connection URL
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@ The PgVector class provides vector search using [PostgreSQL](https://www.postgre
|
|
|
26
26
|
|
|
27
27
|
**pgPoolOptions** (`PoolConfig`): Additional pg pool configuration options
|
|
28
28
|
|
|
29
|
-
## Constructor
|
|
29
|
+
## Constructor examples
|
|
30
30
|
|
|
31
31
|
### Connection String
|
|
32
32
|
|
|
@@ -70,7 +70,7 @@ const vectorStore = new PgVector({
|
|
|
70
70
|
|
|
71
71
|
## Methods
|
|
72
72
|
|
|
73
|
-
### createIndex()
|
|
73
|
+
### `createIndex()`
|
|
74
74
|
|
|
75
75
|
**indexName** (`string`): Name of the index to create
|
|
76
76
|
|
|
@@ -82,7 +82,9 @@ const vectorStore = new PgVector({
|
|
|
82
82
|
|
|
83
83
|
**buildIndex** (`boolean`): Whether to build the index (Default: `true`)
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
**metadataIndexes** (`string[]`): Array of metadata field names to create btree indexes on. Improves query performance when filtering by these metadata fields.
|
|
86
|
+
|
|
87
|
+
#### `IndexConfig`
|
|
86
88
|
|
|
87
89
|
**type** (`'flat' | 'hnsw' | 'ivfflat'`): Index type (Default: `ivfflat`)
|
|
88
90
|
|
|
@@ -112,7 +114,7 @@ HNSW indexes require significant shared memory during construction. For 100K vec
|
|
|
112
114
|
|
|
113
115
|
Higher M values or efConstruction values will increase memory requirements significantly. Adjust your system's shared memory limits if needed.
|
|
114
116
|
|
|
115
|
-
### upsert()
|
|
117
|
+
### `upsert()`
|
|
116
118
|
|
|
117
119
|
**indexName** (`string`): Name of the index to upsert vectors into
|
|
118
120
|
|
|
@@ -122,7 +124,7 @@ Higher M values or efConstruction values will increase memory requirements signi
|
|
|
122
124
|
|
|
123
125
|
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
124
126
|
|
|
125
|
-
### query()
|
|
127
|
+
### `query()`
|
|
126
128
|
|
|
127
129
|
**indexName** (`string`): Name of the index to query
|
|
128
130
|
|
|
@@ -142,11 +144,11 @@ Higher M values or efConstruction values will increase memory requirements signi
|
|
|
142
144
|
|
|
143
145
|
**options.probes** (`number`): IVF search parameter
|
|
144
146
|
|
|
145
|
-
### listIndexes()
|
|
147
|
+
### `listIndexes()`
|
|
146
148
|
|
|
147
149
|
Returns an array of index names as strings.
|
|
148
150
|
|
|
149
|
-
### describeIndex()
|
|
151
|
+
### `describeIndex()`
|
|
150
152
|
|
|
151
153
|
**indexName** (`string`): Name of the index to describe
|
|
152
154
|
|
|
@@ -167,11 +169,11 @@ interface PGIndexStats {
|
|
|
167
169
|
}
|
|
168
170
|
```
|
|
169
171
|
|
|
170
|
-
### deleteIndex()
|
|
172
|
+
### `deleteIndex()`
|
|
171
173
|
|
|
172
174
|
**indexName** (`string`): Name of the index to delete
|
|
173
175
|
|
|
174
|
-
### updateVector()
|
|
176
|
+
### `updateVector()`
|
|
175
177
|
|
|
176
178
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
177
179
|
|
|
@@ -206,7 +208,7 @@ await pgVector.updateVector({
|
|
|
206
208
|
})
|
|
207
209
|
```
|
|
208
210
|
|
|
209
|
-
### deleteVector()
|
|
211
|
+
### `deleteVector()`
|
|
210
212
|
|
|
211
213
|
**indexName** (`string`): Name of the index containing the vector
|
|
212
214
|
|
|
@@ -218,7 +220,7 @@ Deletes a single vector by ID from the specified index.
|
|
|
218
220
|
await pgVector.deleteVector({ indexName: 'my_vectors', id: 'vector123' })
|
|
219
221
|
```
|
|
220
222
|
|
|
221
|
-
### deleteVectors()
|
|
223
|
+
### `deleteVectors()`
|
|
222
224
|
|
|
223
225
|
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
224
226
|
|
|
@@ -228,11 +230,11 @@ Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` m
|
|
|
228
230
|
|
|
229
231
|
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
|
|
230
232
|
|
|
231
|
-
### disconnect()
|
|
233
|
+
### `disconnect()`
|
|
232
234
|
|
|
233
235
|
Closes the database connection pool. Should be called when done using the store.
|
|
234
236
|
|
|
235
|
-
### buildIndex()
|
|
237
|
+
### `buildIndex()`
|
|
236
238
|
|
|
237
239
|
**indexName** (`string`): Name of the index to define
|
|
238
240
|
|
|
@@ -266,7 +268,7 @@ await pgVector.buildIndex('my_vectors', 'cosine', {
|
|
|
266
268
|
})
|
|
267
269
|
```
|
|
268
270
|
|
|
269
|
-
## Response
|
|
271
|
+
## Response types
|
|
270
272
|
|
|
271
273
|
Query results are returned in this format:
|
|
272
274
|
|
|
@@ -279,7 +281,7 @@ interface QueryResult {
|
|
|
279
281
|
}
|
|
280
282
|
```
|
|
281
283
|
|
|
282
|
-
## Error
|
|
284
|
+
## Error handling
|
|
283
285
|
|
|
284
286
|
The store throws typed errors that can be caught:
|
|
285
287
|
|
|
@@ -297,7 +299,7 @@ try {
|
|
|
297
299
|
}
|
|
298
300
|
```
|
|
299
301
|
|
|
300
|
-
## Index
|
|
302
|
+
## Index configuration guide
|
|
301
303
|
|
|
302
304
|
### Performance Optimization
|
|
303
305
|
|
|
@@ -329,14 +331,14 @@ The system automatically detects configuration changes and only rebuilds indexes
|
|
|
329
331
|
- Changed configuration: Index is dropped and rebuilt
|
|
330
332
|
- This prevents the performance issues from unnecessary index recreations
|
|
331
333
|
|
|
332
|
-
## Best
|
|
334
|
+
## Best practices
|
|
333
335
|
|
|
334
336
|
- Regularly evaluate your index configuration to ensure optimal performance.
|
|
335
337
|
- Adjust parameters like `lists` and `m` based on dataset size and query requirements.
|
|
336
338
|
- **Monitor index performance** using `describeIndex()` to track usage
|
|
337
339
|
- Rebuild indexes periodically to maintain efficiency, especially after significant data changes
|
|
338
340
|
|
|
339
|
-
## Direct
|
|
341
|
+
## Direct pool access
|
|
340
342
|
|
|
341
343
|
The `PgVector` class exposes its underlying PostgreSQL connection pool as a public field:
|
|
342
344
|
|
|
@@ -352,7 +354,7 @@ This enables advanced usage such as running direct SQL queries, managing transac
|
|
|
352
354
|
|
|
353
355
|
This design supports advanced use cases but requires careful resource management by the user.
|
|
354
356
|
|
|
355
|
-
## Usage
|
|
357
|
+
## Usage example
|
|
356
358
|
|
|
357
359
|
### Local embeddings with fastembed
|
|
358
360
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Upstash
|
|
1
|
+
# Upstash vector store
|
|
2
2
|
|
|
3
3
|
The UpstashVector class provides vector search using [Upstash Vector](https://upstash.com/vector), a serverless vector database service that provides vector similarity search with metadata filtering capabilities and hybrid search support.
|
|
4
4
|
|
|
5
|
-
## Constructor
|
|
5
|
+
## Constructor options
|
|
6
6
|
|
|
7
7
|
**url** (`string`): Upstash Vector database URL
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ The UpstashVector class provides vector search using [Upstash Vector](https://up
|
|
|
10
10
|
|
|
11
11
|
## Methods
|
|
12
12
|
|
|
13
|
-
### createIndex()
|
|
13
|
+
### `createIndex()`
|
|
14
14
|
|
|
15
15
|
Note: This method is a no-op for Upstash as indexes are created automatically.
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ Note: This method is a no-op for Upstash as indexes are created automatically.
|
|
|
20
20
|
|
|
21
21
|
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
22
22
|
|
|
23
|
-
### upsert()
|
|
23
|
+
### `upsert()`
|
|
24
24
|
|
|
25
25
|
**indexName** (`string`): Name of the index to upsert into
|
|
26
26
|
|
|
@@ -32,7 +32,7 @@ Note: This method is a no-op for Upstash as indexes are created automatically.
|
|
|
32
32
|
|
|
33
33
|
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
34
34
|
|
|
35
|
-
### query()
|
|
35
|
+
### `query()`
|
|
36
36
|
|
|
37
37
|
**indexName** (`string`): Name of the index to query
|
|
38
38
|
|
|
@@ -50,11 +50,11 @@ Note: This method is a no-op for Upstash as indexes are created automatically.
|
|
|
50
50
|
|
|
51
51
|
**queryMode** (`QueryMode`): Search mode: 'DENSE' for dense-only, 'SPARSE' for sparse-only, or 'HYBRID' for combined search
|
|
52
52
|
|
|
53
|
-
### listIndexes()
|
|
53
|
+
### `listIndexes()`
|
|
54
54
|
|
|
55
55
|
Returns an array of index names (namespaces) as strings.
|
|
56
56
|
|
|
57
|
-
### describeIndex()
|
|
57
|
+
### `describeIndex()`
|
|
58
58
|
|
|
59
59
|
**indexName** (`string`): Name of the index to describe
|
|
60
60
|
|
|
@@ -68,11 +68,11 @@ interface IndexStats {
|
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
### deleteIndex()
|
|
71
|
+
### `deleteIndex()`
|
|
72
72
|
|
|
73
73
|
**indexName** (`string`): Name of the index (namespace) to delete
|
|
74
74
|
|
|
75
|
-
### updateVector()
|
|
75
|
+
### `updateVector()`
|
|
76
76
|
|
|
77
77
|
**indexName** (`string`): Name of the index to update
|
|
78
78
|
|
|
@@ -86,7 +86,7 @@ The `update` object can have the following properties:
|
|
|
86
86
|
- `sparseVector` (optional): A sparse vector object with `indices` and `values` arrays for hybrid indexes.
|
|
87
87
|
- `metadata` (optional): A record of key-value pairs for metadata.
|
|
88
88
|
|
|
89
|
-
### deleteVector()
|
|
89
|
+
### `deleteVector()`
|
|
90
90
|
|
|
91
91
|
**indexName** (`string`): Name of the index from which to delete the item
|
|
92
92
|
|
|
@@ -94,7 +94,7 @@ The `update` object can have the following properties:
|
|
|
94
94
|
|
|
95
95
|
Attempts to delete an item by its ID from the specified index. Logs an error message if the deletion fails.
|
|
96
96
|
|
|
97
|
-
## Hybrid
|
|
97
|
+
## Hybrid vector search
|
|
98
98
|
|
|
99
99
|
Upstash Vector supports hybrid search that combines semantic search (dense vectors) with keyword-based search (sparse vectors) for improved relevance and accuracy.
|
|
100
100
|
|
|
@@ -182,7 +182,7 @@ await vectorStore.updateVector({
|
|
|
182
182
|
})
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
## Response
|
|
185
|
+
## Response types
|
|
186
186
|
|
|
187
187
|
Query results are returned in this format:
|
|
188
188
|
|
|
@@ -195,7 +195,7 @@ interface QueryResult {
|
|
|
195
195
|
}
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
## Error
|
|
198
|
+
## Error handling
|
|
199
199
|
|
|
200
200
|
The store throws typed errors that can be caught:
|
|
201
201
|
|
|
@@ -213,14 +213,14 @@ try {
|
|
|
213
213
|
}
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
## Environment
|
|
216
|
+
## Environment variables
|
|
217
217
|
|
|
218
218
|
Required environment variables:
|
|
219
219
|
|
|
220
220
|
- `UPSTASH_VECTOR_URL`: Your Upstash Vector database URL
|
|
221
221
|
- `UPSTASH_VECTOR_TOKEN`: Your Upstash Vector API token
|
|
222
222
|
|
|
223
|
-
## Usage
|
|
223
|
+
## Usage example
|
|
224
224
|
|
|
225
225
|
### Local embeddings with fastembed
|
|
226
226
|
|