hyperspace-sdk-ts 3.0.8 → 3.0.10
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 +38 -0
- package/dist/client.d.ts +7 -1
- package/dist/client.js +7 -1
- package/dist/proto/hyperspace_pb.js +1179 -75
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -69,6 +69,19 @@ Create a new collection.
|
|
|
69
69
|
|
|
70
70
|
Delete collection and all its data.
|
|
71
71
|
|
|
72
|
+
### `listCollections()`
|
|
73
|
+
|
|
74
|
+
Retrieve all active collections for the current tenant.
|
|
75
|
+
Returns `Promise<CollectionInfo[]>`.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
const collections = await client.listCollections();
|
|
79
|
+
for (const col of collections) {
|
|
80
|
+
console.log(`${col.name}: dim=${col.dimension}, metric=${col.metric}, count=${col.count}`);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
72
85
|
### `insert(id, vector, meta?, collection?, durability?)`
|
|
73
86
|
|
|
74
87
|
Insert one vector. Accepts `number[]`, `Float32Array`, `Float64Array`.
|
|
@@ -109,6 +122,31 @@ const results = await client.searchText("How to use HyperspaceDB?", 10, "coll",
|
|
|
109
122
|
});
|
|
110
123
|
```
|
|
111
124
|
|
|
125
|
+
### Geometric Filters (New in v3.0)
|
|
126
|
+
|
|
127
|
+
HyperspaceDB v3.0 introduces advanced spatial filters that run on the engine level:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
// 1. Proximity Search (Ball)
|
|
131
|
+
const ballFilter = {
|
|
132
|
+
inBall: { center: [0.1, 0.2, 0.3], radius: 0.5 }
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// 2. Workspace Constraints (Box)
|
|
136
|
+
const boxFilter = {
|
|
137
|
+
inBox: { minBounds: [-1, -1, -1], maxBounds: [1, 1, 1] }
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// 3. Field of View / Angular Search (Cone)
|
|
141
|
+
const coneFilter = {
|
|
142
|
+
inCone: { axes: [1.0, 0.0, 0.0], apertures: [0.5], cen: 0.01 }
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const results = await client.search([0.1, 0.2, 0.3], 10, "coll", {
|
|
146
|
+
filters: [ballFilter, boxFilter]
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
112
150
|
### `searchBatch(vectors, topK, collection?)`
|
|
113
151
|
|
|
114
152
|
Run multiple searches in one gRPC request to reduce RPC overhead.
|
package/dist/client.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface SearchResult {
|
|
|
26
26
|
[key: string]: TypedMetadataValue;
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
export interface CollectionInfo {
|
|
30
|
+
name: string;
|
|
31
|
+
count: number;
|
|
32
|
+
dimension: number;
|
|
33
|
+
metric: string;
|
|
34
|
+
}
|
|
29
35
|
export interface GraphNode {
|
|
30
36
|
id: number;
|
|
31
37
|
layer: number;
|
|
@@ -69,7 +75,7 @@ export declare class HyperspaceClient {
|
|
|
69
75
|
constructor(host?: string, apiKey?: string, userId?: string);
|
|
70
76
|
createCollection(name: string, dimension: number, metric: string): Promise<boolean>;
|
|
71
77
|
deleteCollection(name: string): Promise<boolean>;
|
|
72
|
-
listCollections(): Promise<
|
|
78
|
+
listCollections(): Promise<CollectionInfo[]>;
|
|
73
79
|
delete(id: number, collection?: string): Promise<boolean>;
|
|
74
80
|
insert(vector: number[] | Float32Array | Float64Array, id: number, meta?: {
|
|
75
81
|
[key: string]: string;
|
package/dist/client.js
CHANGED
|
@@ -274,7 +274,13 @@ class HyperspaceClient {
|
|
|
274
274
|
this.client.listCollections(req, this.metadata, (err, resp) => {
|
|
275
275
|
if (err)
|
|
276
276
|
return reject(err);
|
|
277
|
-
|
|
277
|
+
const list = resp.getCollectionsList().map(c => ({
|
|
278
|
+
name: c.getName(),
|
|
279
|
+
count: c.getCount(),
|
|
280
|
+
dimension: c.getDimension(),
|
|
281
|
+
metric: c.getMetric()
|
|
282
|
+
}));
|
|
283
|
+
resolve(list);
|
|
278
284
|
});
|
|
279
285
|
});
|
|
280
286
|
}
|