@kuralle-agents/vectorize-store 0.9.0 → 0.10.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/README.md +37 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -20,27 +20,60 @@ Peer: `@kuralle-agents/rag`.
|
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
|
+
Pair Vectorize with **Workers AI embeddings** — the embedding model runs inside
|
|
24
|
+
Cloudflare's network (`env.AI` binding), so every query embedding skips the
|
|
25
|
+
public-internet round trip a cloud embedding API costs, and no provider API key
|
|
26
|
+
is needed. `AiSdkEmbedder` accepts the model from
|
|
27
|
+
[`workers-ai-provider`](https://www.npmjs.com/package/workers-ai-provider)
|
|
28
|
+
directly:
|
|
29
|
+
|
|
23
30
|
```ts
|
|
24
31
|
import { CloudflareVectorizeStore } from '@kuralle-agents/vectorize-store';
|
|
25
32
|
import { AiSdkEmbedder, VectorRetriever } from '@kuralle-agents/rag';
|
|
26
|
-
import {
|
|
33
|
+
import { createWorkersAI } from 'workers-ai-provider';
|
|
27
34
|
|
|
28
35
|
interface Env {
|
|
29
36
|
VECTORIZE: VectorizeIndex;
|
|
30
|
-
|
|
37
|
+
AI: Ai;
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
export default {
|
|
34
41
|
async fetch(request: Request, env: Env) {
|
|
35
|
-
const
|
|
42
|
+
const workersai = createWorkersAI({ binding: env.AI });
|
|
36
43
|
const vectorStore = new CloudflareVectorizeStore({ index: env.VECTORIZE });
|
|
37
|
-
const embedder = new AiSdkEmbedder({
|
|
44
|
+
const embedder = new AiSdkEmbedder({
|
|
45
|
+
model: workersai.textEmbeddingModel('@cf/baai/bge-m3'),
|
|
46
|
+
});
|
|
38
47
|
const retriever = new VectorRetriever({ store: vectorStore, embedder, indexName: 'docs', topK: 5 });
|
|
39
48
|
// ...
|
|
40
49
|
},
|
|
41
50
|
};
|
|
42
51
|
```
|
|
43
52
|
|
|
53
|
+
```toml
|
|
54
|
+
# wrangler.toml
|
|
55
|
+
[ai]
|
|
56
|
+
binding = "AI"
|
|
57
|
+
|
|
58
|
+
[[vectorize]]
|
|
59
|
+
binding = "VECTORIZE"
|
|
60
|
+
index_name = "docs"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The Vectorize index dimension must match the embedding model
|
|
64
|
+
(`@cf/baai/bge-m3` → 1024):
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx wrangler vectorize create docs --dimensions=1024 --metric=cosine
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Any other AI SDK embedding provider (OpenAI, Google, Cohere) plugs into
|
|
71
|
+
`AiSdkEmbedder` the same way when you need a specific model — at the cost of a
|
|
72
|
+
cross-internet API call per embedding and a provider key. Whichever model you
|
|
73
|
+
choose, configure `RagPipeline`'s `manifest` (see `@kuralle-agents/rag`) so the
|
|
74
|
+
index is locked to the model that built it — mixing embedding models in one
|
|
75
|
+
index silently corrupts relevance.
|
|
76
|
+
|
|
44
77
|
Use `createVectorRetrievalTool` from `@kuralle-agents/tools` to attach this retriever as an agent tool.
|
|
45
78
|
|
|
46
79
|
## Related
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "git+https://github.com/kuralle/kuralle-agents.git",
|
|
7
7
|
"directory": "packages/kuralle-vectorize-store"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.10.0",
|
|
10
10
|
"description": "Cloudflare Vectorize-backed VectorStore for Kuralle (edge/Workers runtime)",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/index.js",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@kuralle-agents/rag": "0.
|
|
21
|
+
"@kuralle-agents/rag": "0.10.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.11.0",
|
|
25
25
|
"typescript": "^5.3.0",
|
|
26
|
-
"@kuralle-agents/rag": "0.
|
|
26
|
+
"@kuralle-agents/rag": "0.10.0"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|