@anvia/milvus 1.1.4 → 1.1.5
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 +68 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @anvia/milvus
|
|
2
|
+
|
|
3
|
+
Store and search Anvia documents in Milvus. Pair the store with your choice of
|
|
4
|
+
embedding model to add semantic retrieval to agents and applications.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
pnpm add @anvia/milvus @anvia/core @anvia/openai
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`@anvia/openai` supplies the embedding model in this example; other embedding adapters work too.
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
Start Milvus at `localhost:19530` and set `OPENAI_API_KEY`.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { embedDocuments } from "@anvia/core/embeddings";
|
|
20
|
+
import { retrieveDocuments } from "@anvia/core/vector-store";
|
|
21
|
+
import { OpenAIClient } from "@anvia/openai";
|
|
22
|
+
import { MilvusVectorClient } from "@anvia/milvus";
|
|
23
|
+
|
|
24
|
+
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! });
|
|
25
|
+
const model = openai.embeddingModel({ modelId: "text-embedding-3-small" });
|
|
26
|
+
const client = new MilvusVectorClient({ address: "localhost:19530" });
|
|
27
|
+
const store = client.vectorStore<{ id: string; text: string }>({
|
|
28
|
+
collectionName: "support_docs",
|
|
29
|
+
dimensions: 1536,
|
|
30
|
+
metric: "cosine",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
await store.ensure();
|
|
35
|
+
const { documents } = await embedDocuments({
|
|
36
|
+
model,
|
|
37
|
+
documents: [{ id: "password-reset", text: "Reset links expire after 30 minutes." }],
|
|
38
|
+
id: (document) => document.id,
|
|
39
|
+
content: (document) => document.text,
|
|
40
|
+
});
|
|
41
|
+
await store.upsert({ documents });
|
|
42
|
+
|
|
43
|
+
const results = await retrieveDocuments({
|
|
44
|
+
store,
|
|
45
|
+
model,
|
|
46
|
+
query: "How long does a reset link last?",
|
|
47
|
+
topK: 3,
|
|
48
|
+
});
|
|
49
|
+
console.log(results);
|
|
50
|
+
} finally {
|
|
51
|
+
await client.close();
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Store capabilities
|
|
56
|
+
|
|
57
|
+
- Explicit provisioning with `ensure()` and readiness checks with `validate()`.
|
|
58
|
+
- Document replacement, vector search, and metadata filtering.
|
|
59
|
+
- Bring your own embedding model; `store.search()` accepts vectors directly.
|
|
60
|
+
|
|
61
|
+
Configure `address` and optional `token`, or supply a caller-owned native client.
|
|
62
|
+
|
|
63
|
+
Pass `client` to use a preconfigured native SDK client. Injected clients remain caller-owned.
|
|
64
|
+
|
|
65
|
+
## Learn more
|
|
66
|
+
|
|
67
|
+
- [Anvia overview](https://github.com/anvia-hq/anvia/blob/main/README.md)
|
|
68
|
+
- [Contributing](https://github.com/anvia-hq/anvia/blob/main/CONTRIBUTING.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvia/milvus",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Milvus vector store adapter for Anvia.",
|
|
5
5
|
"author": "anvia",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"tsup": "^8.5.0",
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
34
|
"vitest": "^4.1.11",
|
|
35
|
-
"@anvia/core": "1.
|
|
35
|
+
"@anvia/core": "1.6.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@anvia/core": "^1.
|
|
38
|
+
"@anvia/core": "^1.6.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsup src/index.ts --format esm --dts --sourcemap --clean",
|