@superlinked/sie-sdk 0.3.0 → 0.3.2
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 +80 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +80 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -732,7 +732,7 @@ declare class SIEClient {
|
|
|
732
732
|
private detectEndpointType;
|
|
733
733
|
}
|
|
734
734
|
|
|
735
|
-
declare const SDK_VERSION = "0.3.
|
|
735
|
+
declare const SDK_VERSION = "0.3.2";
|
|
736
736
|
|
|
737
737
|
/**
|
|
738
738
|
* Helpers for converting SIE encode results to plain JavaScript types.
|
|
@@ -948,6 +948,39 @@ declare class ModelLoadingError extends SIEError {
|
|
|
948
948
|
readonly model: string | undefined;
|
|
949
949
|
constructor(message: string, model?: string);
|
|
950
950
|
}
|
|
951
|
+
/**
|
|
952
|
+
* Error when the server reports a *terminal* model-load failure.
|
|
953
|
+
*
|
|
954
|
+
* Distinct from {@link ModelLoadingError} — this is thrown on the first
|
|
955
|
+
* response (no retry budget consumed) when the server returns HTTP
|
|
956
|
+
* `502 MODEL_LOAD_FAILED`. The server uses this code for permanent-class
|
|
957
|
+
* failures (gated repos, missing dependencies, unrecognised model
|
|
958
|
+
* architectures) where retrying would waste time. See sie-test#85.
|
|
959
|
+
*
|
|
960
|
+
* Permanent failures will not auto-clear; an operator must fix the
|
|
961
|
+
* underlying cause (e.g. set `HF_TOKEN`, accept the model license on
|
|
962
|
+
* HuggingFace, upgrade `transformers`).
|
|
963
|
+
*/
|
|
964
|
+
declare class ModelLoadFailedError extends ServerError {
|
|
965
|
+
/** The model that was requested */
|
|
966
|
+
readonly model: string | undefined;
|
|
967
|
+
/**
|
|
968
|
+
* Server-side classification: one of `GATED`, `OOM`, `DEPENDENCY`,
|
|
969
|
+
* `NOT_FOUND`, `NETWORK`, `UNKNOWN`. Use this to route to specific
|
|
970
|
+
* remediation paths (e.g. surface a "set HF_TOKEN" hint for `GATED`).
|
|
971
|
+
*/
|
|
972
|
+
readonly errorClass: string | undefined;
|
|
973
|
+
/** Whether the failure is non-retryable per server policy. */
|
|
974
|
+
readonly permanent: boolean;
|
|
975
|
+
/** How many load attempts the server has logged. */
|
|
976
|
+
readonly attempts: number;
|
|
977
|
+
constructor(message: string, options?: {
|
|
978
|
+
model?: string;
|
|
979
|
+
errorClass?: string;
|
|
980
|
+
permanent?: boolean;
|
|
981
|
+
attempts?: number;
|
|
982
|
+
});
|
|
983
|
+
}
|
|
951
984
|
|
|
952
985
|
/**
|
|
953
986
|
* MessagePack serialization with msgpack-numpy compatibility.
|
|
@@ -1053,4 +1086,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
|
|
|
1053
1086
|
*/
|
|
1054
1087
|
declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
|
|
1055
1088
|
|
|
1056
|
-
export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
|
1089
|
+
export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -732,7 +732,7 @@ declare class SIEClient {
|
|
|
732
732
|
private detectEndpointType;
|
|
733
733
|
}
|
|
734
734
|
|
|
735
|
-
declare const SDK_VERSION = "0.3.
|
|
735
|
+
declare const SDK_VERSION = "0.3.2";
|
|
736
736
|
|
|
737
737
|
/**
|
|
738
738
|
* Helpers for converting SIE encode results to plain JavaScript types.
|
|
@@ -948,6 +948,39 @@ declare class ModelLoadingError extends SIEError {
|
|
|
948
948
|
readonly model: string | undefined;
|
|
949
949
|
constructor(message: string, model?: string);
|
|
950
950
|
}
|
|
951
|
+
/**
|
|
952
|
+
* Error when the server reports a *terminal* model-load failure.
|
|
953
|
+
*
|
|
954
|
+
* Distinct from {@link ModelLoadingError} — this is thrown on the first
|
|
955
|
+
* response (no retry budget consumed) when the server returns HTTP
|
|
956
|
+
* `502 MODEL_LOAD_FAILED`. The server uses this code for permanent-class
|
|
957
|
+
* failures (gated repos, missing dependencies, unrecognised model
|
|
958
|
+
* architectures) where retrying would waste time. See sie-test#85.
|
|
959
|
+
*
|
|
960
|
+
* Permanent failures will not auto-clear; an operator must fix the
|
|
961
|
+
* underlying cause (e.g. set `HF_TOKEN`, accept the model license on
|
|
962
|
+
* HuggingFace, upgrade `transformers`).
|
|
963
|
+
*/
|
|
964
|
+
declare class ModelLoadFailedError extends ServerError {
|
|
965
|
+
/** The model that was requested */
|
|
966
|
+
readonly model: string | undefined;
|
|
967
|
+
/**
|
|
968
|
+
* Server-side classification: one of `GATED`, `OOM`, `DEPENDENCY`,
|
|
969
|
+
* `NOT_FOUND`, `NETWORK`, `UNKNOWN`. Use this to route to specific
|
|
970
|
+
* remediation paths (e.g. surface a "set HF_TOKEN" hint for `GATED`).
|
|
971
|
+
*/
|
|
972
|
+
readonly errorClass: string | undefined;
|
|
973
|
+
/** Whether the failure is non-retryable per server policy. */
|
|
974
|
+
readonly permanent: boolean;
|
|
975
|
+
/** How many load attempts the server has logged. */
|
|
976
|
+
readonly attempts: number;
|
|
977
|
+
constructor(message: string, options?: {
|
|
978
|
+
model?: string;
|
|
979
|
+
errorClass?: string;
|
|
980
|
+
permanent?: boolean;
|
|
981
|
+
attempts?: number;
|
|
982
|
+
});
|
|
983
|
+
}
|
|
951
984
|
|
|
952
985
|
/**
|
|
953
986
|
* MessagePack serialization with msgpack-numpy compatibility.
|
|
@@ -1053,4 +1086,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
|
|
|
1053
1086
|
*/
|
|
1054
1087
|
declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
|
|
1055
1088
|
|
|
1056
|
-
export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
|
1089
|
+
export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
package/dist/index.js
CHANGED
|
@@ -85,6 +85,28 @@ var ModelLoadingError = class extends SIEError {
|
|
|
85
85
|
this.model = model;
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
+
var ModelLoadFailedError = class extends ServerError {
|
|
89
|
+
/** The model that was requested */
|
|
90
|
+
model;
|
|
91
|
+
/**
|
|
92
|
+
* Server-side classification: one of `GATED`, `OOM`, `DEPENDENCY`,
|
|
93
|
+
* `NOT_FOUND`, `NETWORK`, `UNKNOWN`. Use this to route to specific
|
|
94
|
+
* remediation paths (e.g. surface a "set HF_TOKEN" hint for `GATED`).
|
|
95
|
+
*/
|
|
96
|
+
errorClass;
|
|
97
|
+
/** Whether the failure is non-retryable per server policy. */
|
|
98
|
+
permanent;
|
|
99
|
+
/** How many load attempts the server has logged. */
|
|
100
|
+
attempts;
|
|
101
|
+
constructor(message, options) {
|
|
102
|
+
super(message, "MODEL_LOAD_FAILED", 502);
|
|
103
|
+
this.name = "ModelLoadFailedError";
|
|
104
|
+
this.model = options?.model;
|
|
105
|
+
this.errorClass = options?.errorClass;
|
|
106
|
+
this.permanent = options?.permanent ?? true;
|
|
107
|
+
this.attempts = options?.attempts ?? 1;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
88
110
|
|
|
89
111
|
// src/internal/constants.ts
|
|
90
112
|
var MSGPACK_CONTENT_TYPE = "application/msgpack";
|
|
@@ -309,7 +331,7 @@ function getRetryAfter2(response) {
|
|
|
309
331
|
const header = response.headers.get("Retry-After");
|
|
310
332
|
return getRetryAfter(header);
|
|
311
333
|
}
|
|
312
|
-
async function
|
|
334
|
+
async function getErrorDetail(response) {
|
|
313
335
|
try {
|
|
314
336
|
const contentType = response.headers.get("content-type") ?? "";
|
|
315
337
|
let data;
|
|
@@ -320,40 +342,73 @@ async function getErrorCode(response) {
|
|
|
320
342
|
data = await response.json();
|
|
321
343
|
}
|
|
322
344
|
if (data.error && typeof data.error === "object") {
|
|
323
|
-
|
|
324
|
-
if (typeof error.code === "string") {
|
|
325
|
-
return error.code;
|
|
326
|
-
}
|
|
345
|
+
return data.error;
|
|
327
346
|
}
|
|
328
347
|
if (data.detail && typeof data.detail === "object") {
|
|
329
|
-
|
|
330
|
-
if (typeof detail.code === "string") {
|
|
331
|
-
return detail.code;
|
|
332
|
-
}
|
|
348
|
+
return data.detail;
|
|
333
349
|
}
|
|
334
350
|
if (typeof data.code === "string") {
|
|
335
|
-
return data
|
|
351
|
+
return data;
|
|
336
352
|
}
|
|
337
353
|
} catch {
|
|
338
354
|
}
|
|
339
355
|
return void 0;
|
|
340
356
|
}
|
|
357
|
+
async function getErrorCode(response) {
|
|
358
|
+
const detail = await getErrorDetail(response);
|
|
359
|
+
if (!detail) return void 0;
|
|
360
|
+
const code = detail.code;
|
|
361
|
+
return typeof code === "string" ? code : void 0;
|
|
362
|
+
}
|
|
363
|
+
async function throwIfModelLoadFailed(response, model) {
|
|
364
|
+
if (response.status !== 502) return;
|
|
365
|
+
const detail = await getErrorDetail(response.clone());
|
|
366
|
+
if (!detail) return;
|
|
367
|
+
if (detail.code !== "MODEL_LOAD_FAILED") return;
|
|
368
|
+
const errorClass = typeof detail.error_class === "string" ? detail.error_class : void 0;
|
|
369
|
+
const permanent = typeof detail.permanent === "boolean" ? detail.permanent : true;
|
|
370
|
+
const attemptsRaw = detail.attempts;
|
|
371
|
+
const parsedAttempts = typeof attemptsRaw === "number" ? attemptsRaw : typeof attemptsRaw === "string" ? Number.parseInt(attemptsRaw, 10) : Number.NaN;
|
|
372
|
+
const attempts = Number.isFinite(parsedAttempts) ? parsedAttempts : 1;
|
|
373
|
+
const message = typeof detail.message === "string" ? detail.message : `Model '${model ?? "?"}' failed to load`;
|
|
374
|
+
throw new ModelLoadFailedError(message, {
|
|
375
|
+
model,
|
|
376
|
+
errorClass,
|
|
377
|
+
permanent,
|
|
378
|
+
attempts
|
|
379
|
+
});
|
|
380
|
+
}
|
|
341
381
|
async function handleError(response, gpu) {
|
|
342
382
|
const { status } = response;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
383
|
+
const detail = await getErrorDetail(response.clone());
|
|
384
|
+
let code;
|
|
385
|
+
let message;
|
|
386
|
+
if (detail) {
|
|
387
|
+
const c = detail.code;
|
|
388
|
+
code = typeof c === "string" ? c : void 0;
|
|
389
|
+
const m = detail.message;
|
|
390
|
+
message = typeof m === "string" ? m : JSON.stringify(detail);
|
|
391
|
+
} else {
|
|
392
|
+
try {
|
|
393
|
+
const data = await response.json();
|
|
394
|
+
if (typeof data.detail === "string") {
|
|
395
|
+
code = typeof data.code === "string" ? data.code : void 0;
|
|
396
|
+
message = data.detail;
|
|
397
|
+
} else if (typeof data.message === "string") {
|
|
398
|
+
code = typeof data.code === "string" ? data.code : void 0;
|
|
399
|
+
message = data.message;
|
|
400
|
+
} else {
|
|
401
|
+
code = typeof data.code === "string" ? data.code : void 0;
|
|
402
|
+
message = response.statusText;
|
|
403
|
+
}
|
|
404
|
+
} catch {
|
|
405
|
+
code = void 0;
|
|
406
|
+
message = response.statusText;
|
|
407
|
+
}
|
|
347
408
|
}
|
|
348
|
-
const code = errorBody.code ?? "UNKNOWN";
|
|
349
|
-
const message = errorBody.detail ?? response.statusText;
|
|
350
409
|
if (status === HTTP_ACCEPTED) {
|
|
351
|
-
const retryAfter = response
|
|
352
|
-
throw new ProvisioningError(
|
|
353
|
-
message,
|
|
354
|
-
gpu,
|
|
355
|
-
retryAfter ? Number.parseInt(retryAfter, 10) * 1e3 : void 0
|
|
356
|
-
);
|
|
410
|
+
const retryAfter = getRetryAfter2(response);
|
|
411
|
+
throw new ProvisioningError(message, gpu, retryAfter);
|
|
357
412
|
}
|
|
358
413
|
if (status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_CLIENT_ERROR_MAX) {
|
|
359
414
|
throw new RequestError(message, code, status);
|
|
@@ -474,7 +529,7 @@ function parseCapacityInfo(data, gpuFilter) {
|
|
|
474
529
|
}
|
|
475
530
|
|
|
476
531
|
// src/version.ts
|
|
477
|
-
var SDK_VERSION = "0.3.
|
|
532
|
+
var SDK_VERSION = "0.3.2";
|
|
478
533
|
|
|
479
534
|
// src/client.ts
|
|
480
535
|
function sleep(ms) {
|
|
@@ -1178,6 +1233,7 @@ var SIEClient = class {
|
|
|
1178
1233
|
await sleep(actualDelay);
|
|
1179
1234
|
continue;
|
|
1180
1235
|
}
|
|
1236
|
+
await throwIfModelLoadFailed(response, model);
|
|
1181
1237
|
if (response.status === 503) {
|
|
1182
1238
|
const clonedResponse = response.clone();
|
|
1183
1239
|
const errorCode = await getErrorCode(clonedResponse);
|
|
@@ -1499,6 +1555,6 @@ function detectImageFormat(bytes) {
|
|
|
1499
1555
|
return "unknown";
|
|
1500
1556
|
}
|
|
1501
1557
|
|
|
1502
|
-
export { LoraLoadingError, ModelLoadingError, PoolError, ProvisioningError, RequestError, SDK_VERSION, SIEClient, SIEConnectionError, SIEError, ServerError, denseEmbedding, detectImageFormat, maxsim, maxsimBatch, maxsimDocuments, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
|
1558
|
+
export { LoraLoadingError, ModelLoadFailedError, ModelLoadingError, PoolError, ProvisioningError, RequestError, SDK_VERSION, SIEClient, SIEConnectionError, SIEError, ServerError, denseEmbedding, detectImageFormat, maxsim, maxsimBatch, maxsimDocuments, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
|
|
1503
1559
|
//# sourceMappingURL=index.js.map
|
|
1504
1560
|
//# sourceMappingURL=index.js.map
|