triangle-utils 1.4.91 → 1.4.93
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.
|
@@ -18,5 +18,6 @@ export declare class UtilsS3Vectors {
|
|
|
18
18
|
query(s3_vector_id_prefix: string, coordinates: number[], num_vectors: number, filters?: Record<string, any> | undefined): Promise<{
|
|
19
19
|
s3_vector_id: string;
|
|
20
20
|
distance: number;
|
|
21
|
+
headers: Record<string, any>;
|
|
21
22
|
}[]>;
|
|
22
23
|
}
|
|
@@ -19,7 +19,7 @@ export class S3Vector {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
function get_s3vectors_input(s3_vector_id) {
|
|
22
|
-
const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)
|
|
22
|
+
const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)\/?([^$\/]*)$/) || []).slice(1, 4);
|
|
23
23
|
if (s3_vector_bucket_name === undefined || s3_vector_index_name === undefined || s3_vector_key === undefined) {
|
|
24
24
|
throw Error("Bad s3_vector_id: " + s3_vector_id);
|
|
25
25
|
}
|
|
@@ -205,15 +205,21 @@ export class UtilsS3Vectors {
|
|
|
205
205
|
console.log("Bad s3_vector_key:", s3_vector_key);
|
|
206
206
|
continue;
|
|
207
207
|
}
|
|
208
|
-
const s3_vector_id = s3_vector_id_prefix +
|
|
208
|
+
const s3_vector_id = s3_vector_id_prefix + s3_vector_key;
|
|
209
209
|
const distance = new_vector.distance;
|
|
210
210
|
if (distance === undefined) {
|
|
211
211
|
console.log("Bad distance:", distance);
|
|
212
212
|
continue;
|
|
213
213
|
}
|
|
214
|
+
const headers = new_vector.metadata;
|
|
215
|
+
if (!(typeof headers === "object" && Object.keys(headers).every((header_id) => typeof header_id === "string"))) {
|
|
216
|
+
console.log("Bad headers:", headers);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
214
219
|
results.push({
|
|
215
220
|
s3_vector_id: s3_vector_id,
|
|
216
|
-
distance: distance
|
|
221
|
+
distance: distance,
|
|
222
|
+
headers: headers
|
|
217
223
|
});
|
|
218
224
|
}
|
|
219
225
|
return results;
|
package/package.json
CHANGED
package/src/UtilsS3Vectors.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface S3VectorsInput {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function get_s3vectors_input(s3_vector_id : string) : S3VectorsInput {
|
|
34
|
-
const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)
|
|
34
|
+
const [s3_vector_bucket_name, s3_vector_index_name, s3_vector_key] = (s3_vector_id.match(/^s3vectors:\/\/([^\/]+)\/([^\/]+)\/?([^$\/]*)$/) || []).slice(1, 4)
|
|
35
35
|
if (s3_vector_bucket_name === undefined || s3_vector_index_name === undefined || s3_vector_key === undefined) {
|
|
36
36
|
throw Error("Bad s3_vector_id: " + s3_vector_id)
|
|
37
37
|
}
|
|
@@ -224,22 +224,28 @@ export class UtilsS3Vectors {
|
|
|
224
224
|
if (new_vectors === undefined) {
|
|
225
225
|
return []
|
|
226
226
|
}
|
|
227
|
-
const results : { s3_vector_id : string, distance : number }[] = []
|
|
227
|
+
const results : { s3_vector_id : string, distance : number, headers : Record<string, any> }[] = []
|
|
228
228
|
for (const new_vector of new_vectors) {
|
|
229
229
|
const s3_vector_key = new_vector.key
|
|
230
230
|
if (s3_vector_key === undefined) {
|
|
231
231
|
console.log("Bad s3_vector_key:", s3_vector_key)
|
|
232
232
|
continue
|
|
233
233
|
}
|
|
234
|
-
const s3_vector_id = s3_vector_id_prefix +
|
|
234
|
+
const s3_vector_id = s3_vector_id_prefix + s3_vector_key
|
|
235
235
|
const distance = new_vector.distance
|
|
236
236
|
if (distance === undefined) {
|
|
237
237
|
console.log("Bad distance:", distance)
|
|
238
238
|
continue
|
|
239
239
|
}
|
|
240
|
+
const headers : any = new_vector.metadata
|
|
241
|
+
if (!(typeof headers === "object" && Object.keys(headers).every((header_id : any) => typeof header_id === "string"))) {
|
|
242
|
+
console.log("Bad headers:", headers)
|
|
243
|
+
continue
|
|
244
|
+
}
|
|
240
245
|
results.push({
|
|
241
246
|
s3_vector_id : s3_vector_id,
|
|
242
|
-
distance : distance
|
|
247
|
+
distance : distance,
|
|
248
|
+
headers : headers
|
|
243
249
|
})
|
|
244
250
|
}
|
|
245
251
|
return results
|