@superlinked/sie-sdk 0.1.8 → 0.1.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/dist/index.cjs +94 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -4
- package/dist/index.d.ts +121 -4
- package/dist/index.js +90 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -107,7 +107,7 @@ var SDK_VERSION_HEADER = "X-SIE-SDK-Version";
|
|
|
107
107
|
var SERVER_VERSION_HEADER = "X-SIE-Server-Version";
|
|
108
108
|
|
|
109
109
|
// src/version.ts
|
|
110
|
-
var SDK_VERSION = "0.1.
|
|
110
|
+
var SDK_VERSION = "0.1.10";
|
|
111
111
|
var EXT_TYPE_NUMPY = 78;
|
|
112
112
|
function parseDtype(dtype) {
|
|
113
113
|
const typeChar = dtype.slice(-2, -1);
|
|
@@ -424,7 +424,28 @@ function parseEntity(data) {
|
|
|
424
424
|
function parseExtractResult(data) {
|
|
425
425
|
return {
|
|
426
426
|
id: data.id,
|
|
427
|
-
entities: data.entities.map(parseEntity)
|
|
427
|
+
entities: data.entities.map(parseEntity),
|
|
428
|
+
relations: (data.relations ?? []).map(
|
|
429
|
+
(r) => ({
|
|
430
|
+
head: r.head,
|
|
431
|
+
tail: r.tail,
|
|
432
|
+
relation: r.relation,
|
|
433
|
+
score: r.score
|
|
434
|
+
})
|
|
435
|
+
),
|
|
436
|
+
classifications: (data.classifications ?? []).map(
|
|
437
|
+
(c) => ({
|
|
438
|
+
label: c.label,
|
|
439
|
+
score: c.score
|
|
440
|
+
})
|
|
441
|
+
),
|
|
442
|
+
objects: (data.objects ?? []).map(
|
|
443
|
+
(o) => ({
|
|
444
|
+
label: o.label,
|
|
445
|
+
score: o.score,
|
|
446
|
+
bbox: o.bbox
|
|
447
|
+
})
|
|
448
|
+
)
|
|
428
449
|
};
|
|
429
450
|
}
|
|
430
451
|
function parseExtractResults(data) {
|
|
@@ -572,6 +593,28 @@ var SIEClient = class {
|
|
|
572
593
|
maxSequenceLength: m.max_sequence_length
|
|
573
594
|
}));
|
|
574
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* Get details for a specific model.
|
|
598
|
+
*
|
|
599
|
+
* Returns model metadata including dimensions, supported inputs/outputs,
|
|
600
|
+
* loaded status, and max sequence length. This is a lightweight call that
|
|
601
|
+
* reads from model config — it does not load the model or trigger inference.
|
|
602
|
+
*
|
|
603
|
+
* @param name - Model name (e.g., "BAAI/bge-m3")
|
|
604
|
+
* @returns Model information
|
|
605
|
+
*/
|
|
606
|
+
async getModel(name) {
|
|
607
|
+
const response = await this.requestJson(`/v1/models/${encodeURIComponent(name)}`, "GET");
|
|
608
|
+
const data = await response.json();
|
|
609
|
+
return {
|
|
610
|
+
name: data.name,
|
|
611
|
+
loaded: data.loaded,
|
|
612
|
+
inputs: data.inputs,
|
|
613
|
+
outputs: data.outputs,
|
|
614
|
+
dims: data.dims,
|
|
615
|
+
maxSequenceLength: data.max_sequence_length
|
|
616
|
+
};
|
|
617
|
+
}
|
|
575
618
|
/**
|
|
576
619
|
* Stream real-time status updates from a worker or router.
|
|
577
620
|
*
|
|
@@ -676,9 +719,6 @@ var SIEClient = class {
|
|
|
676
719
|
query,
|
|
677
720
|
items
|
|
678
721
|
};
|
|
679
|
-
if (options.topK !== void 0) {
|
|
680
|
-
body.top_k = options.topK;
|
|
681
|
-
}
|
|
682
722
|
const waitForCapacity = options.waitForCapacity ?? this.defaultWaitForCapacity;
|
|
683
723
|
const { pool, gpu } = this.parseGpuParam(options.gpu);
|
|
684
724
|
const response = await this.requestWithRetry(
|
|
@@ -1295,6 +1335,50 @@ function toFloat32Array(arr) {
|
|
|
1295
1335
|
return new Float32Array(arr);
|
|
1296
1336
|
}
|
|
1297
1337
|
|
|
1338
|
+
// src/encoding.ts
|
|
1339
|
+
function denseEmbedding(result, strict = true) {
|
|
1340
|
+
const dense = result.dense;
|
|
1341
|
+
if (!dense) {
|
|
1342
|
+
if (strict) {
|
|
1343
|
+
throw new Error("Encode result missing dense embedding");
|
|
1344
|
+
}
|
|
1345
|
+
return [];
|
|
1346
|
+
}
|
|
1347
|
+
return toNumberArray(dense);
|
|
1348
|
+
}
|
|
1349
|
+
function sparseEmbedding(result) {
|
|
1350
|
+
const sparse = result.sparse;
|
|
1351
|
+
if (!sparse) {
|
|
1352
|
+
return { indices: [], values: [] };
|
|
1353
|
+
}
|
|
1354
|
+
return {
|
|
1355
|
+
indices: toNumberArray(sparse.indices),
|
|
1356
|
+
values: toNumberArray(sparse.values)
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
function sparseEmbeddingMap(result) {
|
|
1360
|
+
const sparse = result.sparse;
|
|
1361
|
+
if (!sparse) {
|
|
1362
|
+
return /* @__PURE__ */ new Map();
|
|
1363
|
+
}
|
|
1364
|
+
const indices = toNumberArray(sparse.indices);
|
|
1365
|
+
const values = toNumberArray(sparse.values);
|
|
1366
|
+
const map = /* @__PURE__ */ new Map();
|
|
1367
|
+
for (let i = 0; i < indices.length; i++) {
|
|
1368
|
+
map.set(indices[i], values[i]);
|
|
1369
|
+
}
|
|
1370
|
+
return map;
|
|
1371
|
+
}
|
|
1372
|
+
function normalizeSparseVector(sparse) {
|
|
1373
|
+
return {
|
|
1374
|
+
indices: toNumberArray(sparse.indices),
|
|
1375
|
+
values: toNumberArray(sparse.values)
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
function multivectorEmbedding(raw) {
|
|
1379
|
+
return raw.map((v) => toNumberArray(v));
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1298
1382
|
// src/scoring.ts
|
|
1299
1383
|
function maxsim(query, document) {
|
|
1300
1384
|
if (query.length === 0 || document.length === 0) {
|
|
@@ -1392,11 +1476,16 @@ exports.SIEClient = SIEClient;
|
|
|
1392
1476
|
exports.SIEConnectionError = SIEConnectionError;
|
|
1393
1477
|
exports.SIEError = SIEError;
|
|
1394
1478
|
exports.ServerError = ServerError;
|
|
1479
|
+
exports.denseEmbedding = denseEmbedding;
|
|
1395
1480
|
exports.detectImageFormat = detectImageFormat;
|
|
1396
1481
|
exports.maxsim = maxsim;
|
|
1397
1482
|
exports.maxsimBatch = maxsimBatch;
|
|
1398
1483
|
exports.maxsimDocuments = maxsimDocuments;
|
|
1484
|
+
exports.multivectorEmbedding = multivectorEmbedding;
|
|
1485
|
+
exports.normalizeSparseVector = normalizeSparseVector;
|
|
1399
1486
|
exports.packMessage = packMessage;
|
|
1487
|
+
exports.sparseEmbedding = sparseEmbedding;
|
|
1488
|
+
exports.sparseEmbeddingMap = sparseEmbeddingMap;
|
|
1400
1489
|
exports.toFloat32Array = toFloat32Array;
|
|
1401
1490
|
exports.toImageBytes = toImageBytes;
|
|
1402
1491
|
exports.toImageWireFormat = toImageWireFormat;
|