@mastra/vectorize 0.0.0-error-handler-fix-20251020202607 → 0.0.0-esbuild-bundle-worker-20260807182016
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 +186 -3
- package/LICENSE.md +15 -0
- package/dist/docs/SKILL.md +27 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/guides-rag-retrieval.md +520 -0
- package/dist/docs/references/guides-rag-vector-databases.md +669 -0
- package/dist/docs/references/reference-vectors-vectorize.md +149 -0
- package/dist/index.cjs +377 -374
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +351 -366
- package/dist/index.js.map +1 -1
- package/dist/vector/index.d.ts +5 -2
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +22 -16
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Cloudflare vector store
|
|
4
|
+
|
|
5
|
+
The CloudflareVector class provides vector search using [Cloudflare Vectorize](https://developers.cloudflare.com/vectorize/), a vector database service integrated with Cloudflare's edge network.
|
|
6
|
+
|
|
7
|
+
## Constructor options
|
|
8
|
+
|
|
9
|
+
**accountId** (`string`): Cloudflare account ID
|
|
10
|
+
|
|
11
|
+
**apiToken** (`string`): Cloudflare API token with Vectorize permissions
|
|
12
|
+
|
|
13
|
+
## Methods
|
|
14
|
+
|
|
15
|
+
### `createIndex()`
|
|
16
|
+
|
|
17
|
+
**indexName** (`string`): Name of the index to create
|
|
18
|
+
|
|
19
|
+
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
20
|
+
|
|
21
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (dotproduct maps to dot-product) (Default: `cosine`)
|
|
22
|
+
|
|
23
|
+
### `upsert()`
|
|
24
|
+
|
|
25
|
+
**indexName** (`string`): Name of the index to upsert into
|
|
26
|
+
|
|
27
|
+
**vectors** (`number[][]`): Array of embedding vectors
|
|
28
|
+
|
|
29
|
+
**metadata** (`Record<string, any>[]`): Metadata for each vector
|
|
30
|
+
|
|
31
|
+
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
32
|
+
|
|
33
|
+
### `query()`
|
|
34
|
+
|
|
35
|
+
**indexName** (`string`): Name of the index to query
|
|
36
|
+
|
|
37
|
+
**queryVector** (`number[]`): Query vector to find similar vectors
|
|
38
|
+
|
|
39
|
+
**topK** (`number`): Number of results to return (Default: `10`)
|
|
40
|
+
|
|
41
|
+
**filter** (`Record<string, any>`): Metadata filters for the query
|
|
42
|
+
|
|
43
|
+
**includeVector** (`boolean`): Whether to include vectors in the results (Default: `false`)
|
|
44
|
+
|
|
45
|
+
### `listIndexes()`
|
|
46
|
+
|
|
47
|
+
Returns an array of index names as strings.
|
|
48
|
+
|
|
49
|
+
### `describeIndex()`
|
|
50
|
+
|
|
51
|
+
**indexName** (`string`): Name of the index to describe
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
interface IndexStats {
|
|
57
|
+
dimension: number
|
|
58
|
+
count: number
|
|
59
|
+
metric: 'cosine' | 'euclidean' | 'dotproduct'
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### `deleteIndex()`
|
|
64
|
+
|
|
65
|
+
**indexName** (`string`): Name of the index to delete
|
|
66
|
+
|
|
67
|
+
### `createMetadataIndex()`
|
|
68
|
+
|
|
69
|
+
Creates an index on a metadata field to enable filtering.
|
|
70
|
+
|
|
71
|
+
**indexName** (`string`): Name of the index containing the metadata field
|
|
72
|
+
|
|
73
|
+
**propertyName** (`string`): Name of the metadata field to index
|
|
74
|
+
|
|
75
|
+
**indexType** (`'string' | 'number' | 'boolean'`): Type of the metadata field
|
|
76
|
+
|
|
77
|
+
### `deleteMetadataIndex()`
|
|
78
|
+
|
|
79
|
+
Removes an index from a metadata field.
|
|
80
|
+
|
|
81
|
+
**indexName** (`string`): Name of the index containing the metadata field
|
|
82
|
+
|
|
83
|
+
**propertyName** (`string`): Name of the metadata field to remove indexing from
|
|
84
|
+
|
|
85
|
+
### `listMetadataIndexes()`
|
|
86
|
+
|
|
87
|
+
Lists all metadata field indexes for an index.
|
|
88
|
+
|
|
89
|
+
**indexName** (`string`): Name of the index to list metadata indexes for
|
|
90
|
+
|
|
91
|
+
### `updateVector()`
|
|
92
|
+
|
|
93
|
+
Updates a vector or metadata for a specific ID within an index.
|
|
94
|
+
|
|
95
|
+
**indexName** (`string`): Name of the index containing the ID to update
|
|
96
|
+
|
|
97
|
+
**id** (`string`): Unique identifier of the vector or metadata to update
|
|
98
|
+
|
|
99
|
+
**update** (`{ vector?: number[]; metadata?: Record<string, any>; }`): Object containing the vector and/or metadata to update
|
|
100
|
+
|
|
101
|
+
### `deleteVector()`
|
|
102
|
+
|
|
103
|
+
Deletes a vector and its associated metadata for a specific ID within an index.
|
|
104
|
+
|
|
105
|
+
**indexName** (`string`): Name of the index containing the ID to delete
|
|
106
|
+
|
|
107
|
+
**id** (`string`): Unique identifier of the vector and metadata to delete
|
|
108
|
+
|
|
109
|
+
## Response types
|
|
110
|
+
|
|
111
|
+
Query results are returned in this format:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
interface QueryResult {
|
|
115
|
+
id: string
|
|
116
|
+
score: number
|
|
117
|
+
metadata: Record<string, any>
|
|
118
|
+
vector?: number[]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Error handling
|
|
123
|
+
|
|
124
|
+
The store throws typed errors that can be caught:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
try {
|
|
128
|
+
await store.query({
|
|
129
|
+
indexName: 'index_name',
|
|
130
|
+
queryVector: queryVector,
|
|
131
|
+
})
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (error instanceof VectorStoreError) {
|
|
134
|
+
console.log(error.code) // 'connection_failed' | 'invalid_dimension' | etc
|
|
135
|
+
console.log(error.details) // Additional error context
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Environment variables
|
|
141
|
+
|
|
142
|
+
Required environment variables:
|
|
143
|
+
|
|
144
|
+
- `CLOUDFLARE_ACCOUNT_ID`: Your Cloudflare account ID
|
|
145
|
+
- `CLOUDFLARE_API_TOKEN`: Your Cloudflare API token with Vectorize permissions
|
|
146
|
+
|
|
147
|
+
## Related
|
|
148
|
+
|
|
149
|
+
- [Metadata Filters](https://mastra.ai/reference/rag/metadata-filters)
|